Problem/Motivation
States on radios and checkboxes elements are currently broken until
π
#states cannot check/uncheck checkboxes elements
Fixed
is resolved, but when that issue is fixed another appears.
When the states API manipulates the 'disabled' or 'checked' state of form elements, it looks for the closest 'form-item' or 'form-wrapper' element of the state target and changes the attribute on all of its children.
'checkboxes' and 'radios' elements do not have the 'form-wrapper' class, which causes the wrapper element higher in the hierarchy to be found and have all of its children affected instead of just the desired element.
e.g. with the following form, when the radios element is changed from 'one' to 'two', the checkboxes should be hidden. Instead, the entire fieldset is hidden.
$form['group'] = [
'#type' => 'fieldset',
'#tree' => TRUE,
];
$form['group']['radios'] = [
'#type' => 'radios',
'#title' => 'Radios',
'#options' => [
'one' => 'One',
'two' => 'Two',
],
'#default_value' => 'one',
];
$form['group']['checkboxes'] = [
'#type' => 'checkboxes',
'#title' => 'Checkboxes',
'#options' => [
'alpha' => 'Alpha',
'beta' => 'Beta',
],
'#states' => [
'visible' => [
[':input[name="group[radios]"]' => ['value' => 'one']],
],
];
Proposed resolution
The issues
π
Remove theme_checkboxes() and call theme('container') instead
Needs work
and
#2041825: Remove theme_radios() and call theme('container') instead β
intended to remove the 'checkboxes' and 'radios' templates in favour of a generic 'container' template, which would have the 'form-wrapper' class. These templates can no longer be removed for BC reasons, but they should be made to match the classes of the container template.