You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But in the end this does not have any effect since - as we all know by now - readonly is not supported for radio buttons: http://www.w3.org/TR/WD-forms-970402#readonly READONLY applies to INPUT elements of type TEXT or PASSWORD and to the TEXTAREA element.
So allowing the read_only option on an expandedchoice does not seem to make sense anyway, correct?
The desired effect on the element should be to disable it. But setting disabled on the field type will ignore validation after form submit if the radio buttons have been enabled again by a javascript on client side.
So it looks like the only way to do it is to set the HTML attribute disabled on the field type.
This way it can be enabled again by the client and the submitted value would not be ignored.
Is the choice_attr then the right place to set the disabled attribute (globally)? Or for option as commented by @webda2l .
webdevilopers
changed the title
Unable to set disabled attribute on radio buttons
Unable to globally set disabled attribute on radio buttons
May 6, 2015
Originally I wanted to display radio buttons without the possibility of changing them.
I tried using the
read_only
attribute on my field type first:As expected the
readonly
attribute gets added to theinput
:But in the end this does not have any effect since - as we all know by now -
readonly
is not supported for radio buttons:http://www.w3.org/TR/WD-forms-970402#readonly
READONLY applies to INPUT elements of type TEXT or PASSWORD and to the TEXTAREA element.
So allowing the
read_only
option on anexpanded
choice
does not seem to make sense anyway, correct?The desired effect on the element should be to disable it. But setting
disabled
on the field type will ignore validation after form submit if the radio buttons have been enabled again by a javascript on client side.So it looks like the only way to do it is to set the HTML attribute
disabled
on the field type.This way it can be enabled again by the client and the submitted value would not be ignored.
My attempt for this:
Unfortunately the HTML result does not apply the
disabled
attribute to theinput
but to thediv
around it:I'm not using the Bootstrap theme.
Setting the
attr
seems to be the issue:The
div
uses thewidget_container_attributes
block:https://github.com/symfony/symfony/blob/2.7/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig#L46
While the
input
uses awidget_attributes
block:https://github.com/symfony/symfony/blob/2.7/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig#L93
Are the
attr
passed to the wrong block?Original issue I started:
Possibly related:
The text was updated successfully, but these errors were encountered: