How can I AND two OR statements with the #states feature of Drupal 7? This page explains nicely how to use OR with the #states feature. However, when I try to AND two OR statements, It doesn't seem to AND them together. Is there a way to do this? This is what I tried.

 'visible' =&gt; array(
    array(
      array(':input[name="vehicle"]' =&gt; array('value' =&gt; 'truck')),
      array(':input[name="vehicle"]' =&gt; array('value' =&gt; 'car')),
    ),
    array(
      array(':input[name="mileage"]' =&gt; array('value' =&gt; '10')),
      array(':input[name="mileage"]' =&gt; array('value' =&gt; '20')),
    ),

  ),
I found out that this can be done this way:

$form['non_phd_student'] = array(
    '#type' =&gt; 'item',
    // This #states rule says that the "non_phd_student" item should only
    // be shown if the "student_type" form element is set to "Undergraduate" or "graduate".
    '#states' =&gt; array(
      'visible' =&gt; array(
        array(
          array(':input[name="student_type"]' =&gt; array('value' =&gt; 'undergraduate')),
          array(':input[name="student_type"]' =&gt; array('value' =&gt; 'graduate')),
        )

      ),
    ),
);
$form['non_phd_student']['thanks'] = array(
  '#type' =&gt; 'item',
  '#description' =&gt; t('Thanks for providing your graduate status and your country');
  '#states' =&gt; array(
  //Because this has ['non_phd_student']
  //The or in $form['non_phd_student'] is ANDed into the or of this statement.
  // Action to take: Make visible.
  'visible' =&gt; array(
    array(
      array(':input[name="school_country"]' =&gt; array('value' =&gt; t('Other'))),
      array(':input[name="school_country"]' =&gt; array('value' =&gt; 'UK')),
    )
  ),
),
);


There is another answer that takes more work. We can do this because AND statements can be inside the OR statements. Also, because of Propositional Logic we can get the same results this way:

'visible' =&gt; array(
  array(
    array(
      ':input[name="vehicle"]' =&gt; array('value' =&gt; 'truck'),
      ':input[name="mileage"]' =&gt; array('value' =&gt; '10'),
    ),
    array(
      ':input[name="vehicle"]' =&gt; array('value' =&gt; 'truck'),
      ':input[name="mileage"]' =&gt; array('value' =&gt; '20'),
    ),
    array(
      ':input[name="vehicle"]' =&gt; array('value' =&gt; 'car'),
      ':input[name="mileage"]' =&gt; array('value' =&gt; '20'),
    ),
    array(
      ':input[name="vehicle"]' =&gt; array('value' =&gt; 'car'),
      ':input[name="mileage"]' =&gt; array('value' =&gt; '10'),

    ),
  ),

),