-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Dom crawler form examples #7970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -396,10 +396,19 @@ given text. This method is especially useful because you can use it to return | |
a :class:`Symfony\\Component\\DomCrawler\\Form` object that represents the | ||
form that the button lives in:: | ||
|
||
$form = $crawler->selectButton('validate')->form(); | ||
// button example: <button id="my-super-button" type="submit">My super button</button> | ||
|
||
// you can get button my its name | ||
$form = $crawler->selectButton('My super button')->form(); | ||
|
||
// or by button id (#my-super-button) if button doesn't have a name | ||
$form = $crawler->selectButton('my-super-button')->form(); | ||
|
||
// or you can filter whole form, for example a form has a class attribute: <form class="form-vertical" method="POST"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [...] filter the whole [...] |
||
$crawler->filter('.form-vertical')->form(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this mean exactly? Is the .form-vertical element around the form - so we're looking at a form element inside of it? |
||
|
||
// or "fill" the form fields with data | ||
$form = $crawler->selectButton('validate')->form(array( | ||
$form = $crawler->selectButton('my-super-button')->form(array( | ||
'name' => 'Ryan', | ||
)); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, we are talking about its label, aren't we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. You are correct. User can think about the name attribute :)