How to set Form API's password_confirm in/visible depending on prior select list input? Neither visible nor invisible seems to work on password_confirm. Am I doing something wrong? What else can I try? This is my current code for a subadministrator form, where I'ld like to display the password_confirm only after a user is chosen:

$form['user_select'] = array(
  '#type' =&gt; 'select',
  '#options' =&gt; array('' =&gt; '- ' . t('None') . ' -') + _get_users_by_role('Subadministration'),
  '#required' =&gt; TRUE,
  '#description' =&gt; t('Chose account'),
);

$form['confirm_password'] = array(
  '#type' =&gt; 'password_confirm',
  '#required' =&gt; TRUE,
  '#description' =&gt; t('Type same password in both fields'),
  '#states' =&gt; array(
    'invisible' =&gt; array(
      ':input[name="user_select"]' =&gt; array('value' =&gt; ''),
    ),
  ),
);
A container around the password_confirm did the trick! Fieldset works too.

$form['user_select'] = array(
  '#type' =&gt; 'select',
  '#options' =&gt; array('' =&gt; '- ' . t('None') . ' -') + _get_users_by_role('Subadministration'),
  '#required' =&gt; TRUE,
  '#description' =&gt; t('Chose account'),
);

$form['pass_wrapper'] = array(
    '#type' =&gt; 'container',
    '#states' =&gt; array(
      'invisible' =&gt; array(
        ':input[name="user_select"]' =&gt; array('value' =&gt; ''),
      ),
    ),
  );

$form['pass_wrapper']['confirm_password'] = array(
  '#type' =&gt; 'password_confirm',
  '#required' =&gt; TRUE,
  '#description' =&gt; t('Type same password in both fields'),
);