Sukhrob
Sukhrob

Reputation: 901

Symfony 2 Crawler form submission shows error "LogicException: Unable to submit on a "input" tag."

Let's say, I have a form:

<form action="test.php" method="post">
    <input type="text" name="myinput" value="3" />
    <button>Submit</button>
</form>

This is my filtering and testing with Crawler:

$client = static::createClient();
$crawler = $client->request('GET', 'test.php');

$filter = 'button';
$buttonNode = $crawler->selectButton($crawler->filter($filter));
$this->assertEquals(1, $buttonNode->count()); // this works

$form = $buttonNode->form(); // This shows error "LogicException: Unable to submit on a "input" tag."
$client->submit($form);

Upvotes: 0

Views: 1675

Answers (2)

Andrej Sramko
Andrej Sramko

Reputation: 833

I think that the problem will be in the definition of the button. I will rename it just for the sake of better understanding and add the type there:

<button type="submit">SubmitLabel</button>

Then it should work like this I think:

$client = static::createClient();
$crawler = $client->request('GET', 'test.php');

$buttonCrawlerNode = $crawler->selectButton('SubmitLabel');      
$form = $buttonCrawlerNode->form();
$client->submit($form);

Upvotes: 2

Babou34090
Babou34090

Reputation: 381

You need to find a way like my question.

Or it's just for one test and not many test you can use casperJS

Upvotes: 0

Related Questions