The States API won't pick up the value of a select field with #multiple = TRUE option.
Steps to reproduce:
- Create two fields in a form with the following code:
<?php
$form['dependee'] = array(
'#type'=> 'select',
'#options'=> array(
'a'=> 'Option A',
'b'=> 'Option B',
'c'=> 'Option C',
),
'#multiple'=> TRUE,
);
$form['dependent'] = array(
'#type'=> 'textfield',
'#states'=> array(
'visible'=> array(
'select[name="dependee[]"]'=> array('value'=> array('a')),
),
),
);
?>
The dependent field will stay hidden regardless of the value of the dependee. This happens because the value of a multiple select field is an array, and States tries to compare it with the reference with a === operator, which returns always false.
The proposed solution is to add a handler for arrays in states.Dependent.comparisons. This works with ANDed values:
'select[name="dependee[]"]' => array('value' => array('a', 'b')),
and with ORs as well (following the syntax proposed in #735528: FAPI #states: Fix conditionals to allow OR and XOR constructions):
'select[name="dependee[]"]' => array('value' => array('a')), array('value' => array('c'))