Skip to content

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

Closed
wants to merge 5 commits into from
Closed

Conversation

uikolas
Copy link
Contributor

@uikolas uikolas commented May 30, 2017

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

@uikolas uikolas changed the title Uikolas dom crawler Dom crawler form examples May 30, 2017
Copy link
Member

@weaverryan weaverryan left a 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!

$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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its name

Copy link
Member

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?

Copy link
Contributor Author

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?

// 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
Copy link
Member

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"

$form = $crawler->selectButton('my-super-button')->form();

// or you can filter whole form
$crawler->filter('.form-vertical')->form();
Copy link
Member

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?

@xabbuh xabbuh added this to the 2.7 milestone Jun 18, 2017
@uikolas
Copy link
Contributor Author

uikolas commented Jun 19, 2017

So, sorry for misspelling.

$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
Copy link
Member

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?

Copy link
Contributor Author

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 :)

$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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by

// 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] if the button [...]

// 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">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] filter the whole [...]

@weaverryan
Copy link
Member

This is GREAT! I really like all the examples with comments to explain them. Easy to read and super clear. Thanks @uikolas!

weaverryan added a commit that referenced this pull request Jul 6, 2017
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
@weaverryan weaverryan closed this Jul 6, 2017
@uikolas uikolas deleted the uikolas-dom_crawler branch November 19, 2017 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants