Form states with "and" and "or" conditions Using form API in D7, I need to use from states to setup a visible input with this condition :

field1 = value A AND (field2 = value B OR value C OR value D)


Something like this, but this example doesn't run :

'#states' =&gt; array(
      'visible' =&gt; array(
        array(':input[name="question_inhabitant_type"]' =&gt; array('value' =&gt; 'owner')),
        'AND',
        array(':input[name="question_building_type"]' =&gt; array('value' =&gt; 'house100')),
        'OR',
        array(':input[name="question_building_type"]' =&gt; array('value' =&gt; 'house150')),
        'OR',
        array(':input[name="question_building_type"]' =&gt; array('value' =&gt; 'house200')),
      ),
    ),


Any idea?
You can use or/xor in form states. For and, continuation of the conditions is enough. For example your code the condition can be written as:


'#states' =&gt; array(
  'visible' =&gt; array(
    array(':input[name="question_inhabitant_type"]' =&gt; array('value' =&gt; 'owner')),
    array(
      array(':input[name="question_building_type"]' =&gt; array('value' =&gt; 'house100')),
      'or',
      array(':input[name="question_building_type"]' =&gt; array('value' =&gt; 'house150')),
      'or',
      array(':input[name="question_building_type"]' =&gt; array('value' =&gt; 'house200')),
    ),
  ),
),



Note: jQuery 1.7 doesn't support OR/XOR's for #states. So, make sure you have latest jQuery version on you site (>1.7).

Unfortunately the above code didn't worked as expected. Please help through your comments to correct it. Also meanwhile you can try this code:

'#states' =&gt; array(
  'visible' =&gt; array(
    ':input[name="question_inhabitant_type"]' =&gt; array('value' =&gt; 'owner'),
    ':input[name="question_building_type"]' =&gt; array(
      array('value' =&gt; 'house100'),
      array('value' =&gt; 'house150'),
      array('value' =&gt; 'house200'),
    ),
  ),
),