-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
ChoiceFormField::isDisabled for checkbox #8348
New issue
Have a question about this project? Sign up for a free GitHub account to open an i 8000 ssue 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
Comments
@tamirvs The |
so it's not meant to be used on checkbox? |
Looking at the original commit this method was designed for use with radio buttons. As @jfsimon says its name is misleading because it only pays attention to the currently selected option - if no options are selected, it is supposed to return false. I'd expected it to return true if the actual field is disabled, but it's looking at the options within. Maybe it's named inappropriately, and should be titled In any case, I'm not sure the way this method works extends to all the different ways the class can be configured (especially as it's possible for multi-checkboxes / radios to be configured via the class). We could provide an optional parameter to the method which would dictate how to assert the disabled status - possible values being
the former would be the default, maintaining the current behaviour for the case of single selects. In the case of multiple selects, all of the selected options would have to be disabled for The middle case would return Happy to do a patch if this sounds sensible to someone else. |
The In case of a radio button this might make sense, as all the radio buttons share the same name. In case of the checkbox I think the value shouldn't matter. There's always a single checkbox in each In case of a select with options it's a bit more complex, as both the select node can be disabled, as well as each of the options. Current logic will only check the currently selected option, and ignore the select node. I suggest we don't verify option's value for checkboxes. |
The handling of select nodes should be fixed by #17542 I guess. |
Thank you for this suggestion. |
Friendly ping? Should this still be open? I will close if I don't hear anything. |
Yes, it should still be open. |
…ue` for unchecked disabled checkboxes (MatTheCat) This PR was merged into the 6.4 branch. Discussion ---------- [DomCrawler] Make `ChoiceFormField::isDisabled` return `true` for unchecked disabled checkboxes | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #8348 | License | MIT `ChoiceFormField::isDisabled`’s PHPDoc reads > Check if the current selected option is disabled. But a checkbox really embeds two options: either you check it, or not; which means it always has a selected option. Then, if a checkbox is disabled, these two options are too. So, `ChoiceFormField::isDisabled` should return `true` for disabled checkboxes, checked or not. This also matches what you intuitively would expect from this method. Commits ------- 9807ce6 [DomCrawler] Make `ChoiceFormField::isDisabled` return `true` for unchecked disabled checkboxes
Checking if a checkbox is disabled using
isDisabled()
returns false even when the checkbox really is disabled.I looked through the code and I think the problem is this line because when I dumped the
ChoiceFormField
checkbox object this is what I got:So obviously this
$option['value'] == $this->value
is false..If when building the form I add an option
'value' => null
to the checkbox form it works just fine.Shouldn't the checkbox
isDisabled
function be different than the one for other choice inputs?The text was updated successfully, but these errors were encountered: