Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Merged
fabpot merged 1 commit intosymfony:masterfromstof:html5_form
Dec 2, 2016

Conversation

@stof
Copy link
Member

@stofstof commentedNov 9, 2016

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsn/a
LicenseMIT
Doc PRn/a

This adds supports for theformaction andformmethod 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 implementtarget either (the Crawler does not deal with frame-based pages anyway)
  • formnovalidate is ignored, as we don't automatically disable the form validation onnovalidate 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 ignoreenctype (we always submit file fields, even when missing the proper enctype)

Simperfit reacted with thumbs up emoji
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');

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?

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.

javiereguiluz reacted with thumbs up emoji
Copy link
MemberAuthor

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');

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.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

done

@javiereguiluz
Copy link
Member

👍

Status: reviewed

@fabpot
Copy link
Member

Thank you@stof.

@fabpotfabpot closed thisDec 2, 2016
@fabpotfabpot merged commit717cf8a intosymfony:masterDec 2, 2016
fabpot added a commit that referenced this pull requestDec 2, 2016
… 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
@stofstof deleted the html5_form branchDecember 2, 2016 13:11
@nicolas-grekasnicolas-grekas modified the milestones:3.x,3.3Mar 24, 2017
@fabpotfabpot mentioned this pull requestMay 1, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@javiereguiluzjaviereguiluzjaviereguiluz left review comments

+2 more reviewers

@aik099aik099aik099 left review comments

@SimperfitSimperfitSimperfit approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

7 participants

@stof@javiereguiluz@fabpot@aik099@Simperfit@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp