Form radios/checkboxes elements should have js-form-wrapper class

Created on 19 February 2018, over 6 years ago
Updated 11 December 2023, 9 months ago

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.

πŸ› Bug report
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component
FormΒ  β†’

Last updated 1 minute ago

Created by

πŸ‡¨πŸ‡¦Canada gapple

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs frontend framework manager review

    Used to alert the fron-tend framework manager core committer(s) that a front-end focused issue significantly impacts (or has the potential to impact) multiple subsystems or represents a significant change or addition in architecture or public APIs, and their signoff is needed (see the governance policy for more information). If an issue significantly impacts only one subsystem, use Needs subsystem maintainer review instead, and make sure the issue component is set to the correct subsystem.

  • Needs change record

    A change record needs to be drafted before an issue is committed. Note: Change records used to be called change notifications.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¬πŸ‡·Greece dimitriskr

    Attached is a screencast with the form code from the IS, running in latest 11.x with Olivero. I believe this issue can close as outdated?

  • Status changed to Postponed: needs info 9 months ago
  • πŸ‡¬πŸ‡·Greece dimitriskr

    Attached is a screencast with the form code from the IS, running in latest 11.x with Olivero and cannot reproduce the bug.

    If someone else sees it, please write some steps to reproduce

Production build 0.71.5 2024