It appears that the table FAPI does not honor the #states parameter.

  $form['notify'] = array(
    '#type' => 'table',
    '#header' => array(t('Role'), t('Count')),
    '#attributes' => array(
      'id' => 'fisma-user-settings-form',
      ),
    '#caption' => t('Roles to Notify of Account Action'),
    '#states' => array(
      'invisible' => array(
        ':input[name="enable"]' => array('value' => '0'),
        ),
      ),
    );

Whereas, if I duplicate the code on a fieldset, it works fine.

  $form['emails'] = array(
    '#type' => 'fieldset',
    '#title' => t('Email subjects and bodies'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#description' => t('The role(s) chosen above will be notified when a user account is created, updated, or deleted.')
      . ' ' . t('The subject and body fields for each type of email are specified below.')
      . ' ' . t('The following substitutions are available:')
      . '<ul><li>' . t('@actor - the person who performed the action.')
      . '</li><li>' . t('!user - the link to the user account.')
      . '</li><li>' . t('@name - the name on the user account.')
      . '</ul>',
    '#states' => array(
      'invisible' => array(
        ':input[name="enable"]' => array('value' => '0'),
        ),
      ),
    );

Comments

NancyDru created an issue. See original summary.

Dave Reid’s picture

Status: Active » Closed (works as designed)

No, tables do not honor states. You'd need to wrap the table in a fieldset or a container element in order for this to work. This is by design and you'd need to file an issue in core to resolve this as this element is not provided by this module.

Dave Reid’s picture

To clarify, I don't believe the table element in Drupal 8 supports states. It would need to be fixed there first.