Drupal #states how to make it work

352 Views Asked by At

I'm trying to make #states work on drupal, I have a select field like this :

 $form['options'][$default_set_id]['none']['order_fields'][$field_name] = array(
    '#type' => $widget_types[$order_field['widget']['type']],
    '#suffix' => '<div class="field-description">' . $order_field['description'] . '</div>',
    '#title' => $order_field['label'],
    '#default_value' => '',
    '#options' => field_info_field($field_name)['settings']['allowed_values']
  );

and my field that need the #states :

$form['options'][$default_set_id]['none']['order_fields'][$field_name] = array(
    '#type' => $widget_types[$order_field['widget']['type']],
    '#suffix' => '<div class="field-description">' . $order_field['description'] . '</div>',
    '#title' => $order_field['label'],
    '#default_value' => isset($current_options['order_fields'][$field_name]) ? $current_options['order_fields'][$field_name] : '',
     '#states' => array(
      'visible' => array(
        ':select[name="field_transport_rdv"]' => array('value' => 'autre'),
      )
    )

  );

I'm doing all like in the documentation and examples I found in internet, but it seems not work, anyone have an idea ?

0

There are 0 best solutions below