Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292853

[D7] #states api "required" state incorrectly adds required-asterisk to all individual radio inputs for a "radios" element

$
0
0

This bug must have been filed before, but I searched and couldn't find it.
This is a different bug from #1592688: #states can cause the form "required" mark to appear more than once on the same element

Using #states api to create an element with "required" state incorrectly adds required-asterisk to labels of each individual radio input for a "radios" element, instead of just the top-level label for the form-type-radios element.

Example:

function my_fake_form() {
  return array(
      'field_A' => array(
        '#type' => 'radios',
        '#title' => t('Field A'),
        '#required' => TRUE,
        '#options' => array(
          'one' => t('One'),
          'two' => t('Two'),
        ),
        'field_B' => array(
          '#type' => 'radios',
          '#title' => t('Select an option'),
          '#options' => array(
            'three' => t('Three'),
            'four' => t('Four'),
          ),
          '#states' => array(
            'required' => array(
              'input[name="field_A"]' => array('value' => 'one'),
            ),
          ),
        )
     );
}

Observed output is (pseudo code):
div-field-a
- field A
-- one
-- two
div-field-b
- field B *
-- three *
-- four *

Expected output is:
div-field-a
- field A
-- one
-- two
div-field-b
- field B *
-- three
-- four


Viewing all articles
Browse latest Browse all 292853

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>