-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DomCrawler] Skip disabled fields processing in Form #34059
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
sbogx
commented
Oct 22, 2019
Q | A |
---|---|
Branch? | 3.4 |
Bug fix? | yes |
New feature? | no |
Deprecations? | no |
Tickets | Fix #28179 |
License | MIT |
Can you give us more details as to why this is needed? |
It is indeed a behaviour change. Normally if a field is disabled in a form, it is completely ignored and that's what I intended to fix with the changes. |
@nicolas-grekas , I created the following mini-repo for demoing the issue https://github.com/sbogx/DomCrawler-disabled |
Thank you @sbogx. |
This PR was merged into the 3.4 branch. Discussion ---------- [DomCrawler] Skip disabled fields processing in Form | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #28179 | License | MIT Commits ------- c73b042 bug #28179 [DomCrawler] Skip disabled fields processing in Form
In light of #35923 I think we should consider reverting this. Maybe to fix the original poster's problem we need to detect when multiple fields have the same name and enact some logic? |
Hi @alexpott, the point of the DomCrawler is to simulate a normal functioning form, this change ensures this behaviour when processing disabled fields. I recommend checking the example repo. |
@sbogx well then this fix requires changes to a lot of things that use domcrawler for example \Behat\Mink\Driver\BrowserKitDriver::isChecked(). I'm not sure that I agree that sole purpose of the
To quote the readme it's purpose is to
This change has broken the ability to navigate the DOM for disabled fields and check their values. |
We should revert the PR for sure. Changing behavior and affecting legit use cases should not happen in a bugfix release. |
…ssing in Form" (dmaicher) This PR was merged into the 3.4 branch. Discussion ---------- Revert "bug #28179 [DomCrawler] Skip disabled fields processing in Form" | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | #35923 | License | MIT | Doc PR | - Reverts #34059 See #35923 Commits ------- af17f5a Revert "bug #28179 [DomCrawler] Skip disabled fields processing in Form"
Lock on the previous version 4.4.4 which was working as expected. Ref. symfony/symfony#34059
Disabled form fields are perfectly normal and should be supported by dom-crawler. I checked the demo repo https://github.com/sbogx/DomCrawler-disabled and dom-crawler already has support for selecting those fields. Selecting the enabled element
Selecting the disabled element
The test case is doing the following:
but since Note that it is allowed in HTML to have identical names for different form elements, regardless whether or not some of those fields are disabled. This is also valid HTML:
In the above example you also don't get the expected results back from |
@pfrenssen My issue was not whether DomCrawler should or should not support disabled fields. I know how the implementation works and how to get a specific disabled input. The issue that this PR is trying to fix is to make the The problem originates from In this case, maybe it would be better to have a new, separate collection of values that will be used by |
The Submitting of forms is not handled by this object but by client side code (e.g. Codeception). The In real life if a form is submitted containing multiple fields with the same name, then the value of the last defined field is submitted, and all others are discarded. So a proper fix could be something like this:
|
Hmm I tried it and it has the same result. It seems |