Drupal - Empty value "- Select -" does not appear for select fields with states requirement

To force the "empty option", assign it with something like:

"#empty_option"=>t('- Select -'),

you need change this:

 'visible' => Array('select[name=first_select]' => array('value' => '2')),
 'required' => Array('select[name=first_select]' => array('value' => '2')),

select to :input

the correct code is :

 'visible' => Array(':input[name="first_select"]' => array('value' => '2')),
 'required' => Array(':input[name="first_select"]' => array('value' => '2')),

Tags:

Forms

7