#states option in Drupal FORMS

Events happening in the community are now at Drupal community events on www.drupal.org.
cprofessionals's picture

This is not so much of a "Discussion" as a documentation of the resolution from todays meeting and an VERY appreciative "THANK YOU" to Jennifer for her mentorship. Jennifer, YOU ROCK!

Here was my solution for "ajax-ish" state detection on a Managed_File element within a Drupal Form.

      $form['entity_ajax']['entity_type'] = array(
        '#title' => t('Entity Type'),
        '#type' => 'select',
        '#description' => 'Select the entity type to import.',
        '#options' => array_combine($entity_types, $entity_types),
        '#empty_option' => t($this->select_verbiage),
        '#default_value' => '',
        '#value' => $this->entity_type ,
        '#states' => array(
          'invisible' => array(
            ':input[name="import_file[fids]"]' => array(
              'empty' => TRUE,
            ),
          ),
        ),
      );

Comments

Woot!

jhodgdon's picture

Glad you got it working -- yeah, that #states feature is cool!
--Jennifer

Spokane, WA

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: