Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[DomCrawler] Add support for formaction and formmethod attributes#20467
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| publicfunctiontestGetUriWithActionOverride() | ||
| { | ||
| $form =$this->createForm('<form action="/foo"><button type="submit" formaction="/bar" /></form>',null,'http://localhost/foo/'); | ||
| $this->assertEquals('http://localhost/bar',$form->getUri(),'->getUri() returns absolute URIs'); |
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.
Here you are testinggetUri() but in your PR you have changedgetRawUri(), right?
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.
Maybe becausegetRawUri is a protected method (can't be tested directly), which is called by publicgetUri method.
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.
indeed.getUri (defined in the parent class) callsgetRawUri and then resolve the URI to account for non-absolute ones (like in this test)
| { | ||
| $form =$this->createForm('<form action="/foo"><button type="submit" formaction="/bar" /></form>',null,'http://localhost/foo/'); | ||
| $this->assertEquals('http://localhost/bar',$form->getUri(),'->getUri() returns absolute URIs'); | ||
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.
Extra blank line should be removed.
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.
done
javiereguiluz commentedNov 10, 2016
👍 Status: reviewed |
fabpot commentedDec 2, 2016
Thank you@stof. |
… attributes (stof)This PR was merged into the 3.3-dev branch.Discussion----------[DomCrawler] Add support for formaction and formmethod attributes| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | n/a| License | MIT| Doc PR | n/aThis adds supports for the ``formaction`` and ``formmethod`` of submit elements, which override the values defined on the ``<form>`` element.This works only when you call ``$crawler->form()`` on a Crawler containing a button, not when it contains the ``<form>`` itself of course (as the button override is applied only when using this button to submit, not when using another way).Other button-level overrides are not implemented:- ``formtarget`` is useless as we don't implement ``target`` either (the Crawler does not deal with frame-based pages anyway)- ``formnovalidate`` is ignored, as we don't automatically disable the form validation on ``novalidate`` either, but we require an explicit disabling instead (this might be subject to a separate PR though, as it could make sense)- ``formenctype`` is ignored as we also ignore ``enctype`` (we always submit file fields, even when missing the proper enctype)Commits-------717cf8a [DomCrawler] Add support for formaction and formmethod attributes
This adds supports for the
formactionandformmethodof submit elements, which override the values defined on the<form>element.This works only when you call
$crawler->form()on a Crawler containing a button, not when it contains the<form>itself of course (as the button override is applied only when using this button to submit, not when using another way).Other button-level overrides are not implemented:
formtargetis useless as we don't implementtargeteither (the Crawler does not deal with frame-based pages anyway)formnovalidateis ignored, as we don't automatically disable the form validation onnovalidateeither, but we require an explicit disabling instead (this might be subject to a separate PR though, as it could make sense)formenctypeis ignored as we also ignoreenctype(we always submit file fields, even when missing the proper enctype)