-
-
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
Conversation
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.
A few comments, but I do like having the added examples!
components/dom_crawler.rst
Outdated
$form = $crawler->selectButton('validate')->form(); | ||
// button example: <button id="my-super-button" type="submit">My super button</button> | ||
|
||
// you can get button my it's name |
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.
its name
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.
So, it matches by button text? What if it's an input type="submit" - does it use the name attribute then?
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.
Sorry, I didn't understand what do you mean with:
What if it's an input type="submit" - does it use the name attribute then?
components/dom_crawler.rst
Outdated
// you can get button my it's name | ||
$form = $crawler->selectButton('My super button')->form(); | ||
|
||
// or by by button id (#my-super-button) if button don't have name |
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.
You have "by by"
And change to "doesn't have a name"
components/dom_crawler.rst
Outdated
$form = $crawler->selectButton('my-super-button')->form(); | ||
|
||
// or you can filter whole form | ||
$crawler->filter('.form-vertical')->form(); |
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.
What does this mean exactly? Is the .form-vertical element around the form - so we're looking at a form element inside of it?
So, sorry for misspelling. |
components/dom_crawler.rst
Outdated
$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 |
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 :)
components/dom_crawler.rst
Outdated
$form = $crawler->selectButton('validate')->form(); | ||
// button example: <button id="my-super-button" type="submit">My super button</button> | ||
|
||
// you can get button my its label |
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.
by
components/dom_crawler.rst
Outdated
// you can get button my its label | ||
$form = $crawler->selectButton('My super button')->form(); | ||
|
||
// or by button id (#my-super-button) if button doesn't have a label |
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.
[...] if the button [...]
components/dom_crawler.rst
Outdated
// or by button id (#my-super-button) if button doesn't have a label | ||
$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 comment
The reason will be displayed to describe this comment to others. Learn more.
[...] filter the whole [...]
This is GREAT! I really like all the examples with comments to explain them. Easy to read and super clear. Thanks @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
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