Skip to main content
Improve formatting
Source Link
leymannx
  • 18.8k
  • 6
  • 72
  • 126

I was able to do it this way in Drupal 8:

          '#states' => array(
            'required' => array(
              array(':input[name="host_info"]' => array('value' => 'SSH2')),
             ),
           ),
'#states' => [
  'required' => [
    [':input[name="host_info"]' => ['value' => 'SSH2']],
  ],
],

Don't put t('SSH2').t('SSH2') this will put the translation of it there instead of the value of the option which is an untranslated SSH2.

I suspect that this would work for Drupal 7 too.

I was able to do it this way in Drupal 8:

          '#states' => array(
            'required' => array(
              array(':input[name="host_info"]' => array('value' => 'SSH2')),
             ),
           ),

Don't put t('SSH2'). this will put the translation of it there instead of the value of the option which is an untranslated SSH2.

I suspect that this would work for Drupal 7 too.

I was able to do it this way in Drupal 8:

'#states' => [
  'required' => [
    [':input[name="host_info"]' => ['value' => 'SSH2']],
  ],
],

Don't put t('SSH2') this will put the translation of it there instead of the value of the option which is an untranslated SSH2.

I suspect that this would work for Drupal 7 too.

added 128 characters in body
Source Link

I was able to do it this way in Drupal 8:

          '#states' => array(
            'required' => array(
              array(':input[name="my_country"]'input[name="host_info"]' => array('value' => 'US''SSH2')),
             ),
           ),

Don't put t('SSH2'). this will put the translation of it there instead of the value of the option which is an untranslated SSH2.

I suspect that this would work for Drupal 7 too.

I was able to do it this way in Drupal 8:

          '#states' => array(
            'required' => array(
              array(':input[name="my_country"]' => array('value' => 'US')),
             ),
           ),

I suspect that this would work for Drupal 7 too.

I was able to do it this way in Drupal 8:

          '#states' => array(
            'required' => array(
              array(':input[name="host_info"]' => array('value' => 'SSH2')),
             ),
           ),

Don't put t('SSH2'). this will put the translation of it there instead of the value of the option which is an untranslated SSH2.

I suspect that this would work for Drupal 7 too.

Source Link

I was able to do it this way in Drupal 8:

          '#states' => array(
            'required' => array(
              array(':input[name="my_country"]' => array('value' => 'US')),
             ),
           ),

I suspect that this would work for Drupal 7 too.