Skip to content

Commit cd8b892

Browse files
committed
feature #7970 Dom crawler form examples (uikolas)
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #7970). Discussion ---------- Dom crawler form examples Added more examples, how to get crawler form. I think for new users it's kinda useful, these examples. Especially if form button doens't contains name Commits ------- 36e3508 Small mistype edits 16db597 Changed text how to get button label 096c1c0 Small misspelling fixes cdf1a5b Small typo fix fce7657 Edited to show more ways, to get crawler form
2 parents 8013d78 + 36e3508 commit cd8b892

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

components/dom_crawler.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,19 @@ given text. This method is especially useful because you can use it to return
338338
a :class:`Symfony\\Component\\DomCrawler\\Form` object that represents the
339339
form that the button lives in::
340340

341-
$form = $crawler->selectButton('validate')->form();
341+
// button example: <button id="my-super-button" type="submit">My super button</button>
342+
343+
// you can get button by its label
344+
$form = $crawler->selectButton('My super button')->form();
345+
346+
// or by button id (#my-super-button) if the button doesn't have a label
347+
$form = $crawler->selectButton('my-super-button')->form();
348+
349+
// or you can filter the whole form, for example a form has a class attribute: <form class="form-vertical" method="POST">
350+
$crawler->filter('.form-vertical')->form();
342351

343352
// or "fill" the form fields with data
344-
$form = $crawler->selectButton('validate')->form(array(
353+
$form = $crawler->selectButton('my-super-button')->form(array(
345354
'name' => 'Ryan',
346355
));
347356

0 commit comments

Comments
 (0)