0

In my form I have the following:

$form['text_2'] = [
    '#type' => 'textfield',
    '#title' => $this->t('Text'),
    '#default_value' => isset($config['text_2']) ? $config['text_2'] : '',
    '#states' => [
        'visible' => [
            ':input[name="search_radio"]' => ['checked' => true],
        ],
    ]
];

The search_radio field is:

$form['search_radio'] = array(
  '#type' => 'checkbox',
  '#title' => $this->t('Enable radio buttons'),
  '#default_value' => isset($config['search_radio']) ? $config['search_radio'] : false,
);

Checking and unchecking the search_radio field has no effect at all on this field.

  • 1
    Can you post your "search_radio" field also? – Ajay Reddy Aug 17 '18 at 5:25
  • I've added it, above. – JAyenGreen Aug 17 '18 at 11:25
  • Above code working good in my system Can you post any attachments if possible? So that it will be good to look more. Also check is there any JS errors in page. – Ajay Reddy Aug 17 '18 at 11:29
  • What type of attachments? There is no console activity whatsoever when checking and unchecking. – JAyenGreen Aug 17 '18 at 13:46
  • I have it working. Switching from name= to data-drupal-selector= seems to have overcome whatever the issue was. – JAyenGreen Aug 17 '18 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.