Using states in Drupal 7 form to provide 'select all' functionality I'm trying to use this to achieve the functionality of having a checkbox that, when selected, causes a range of checkboxes to all be selected. I made the selectall box a separate form field, and it looks like this, and works not a lick:

$form['report_group']['selectall'] = array(
  '#type' =&gt; 'checkbox',
  '#default_value' =&gt; 0,
);

$form['report_group']['boxes'] = array(
  '#type' =&gt; 'checkboxes',
  '#options' =&gt; $boxes,
  '#states' =&gt; array(
    'checked' =&gt; array(
      ':input[name="report_group[selectall]"]' =&gt; array('checked' =&gt; TRUE),   
    ),
  ),
I don't think the "checked" property works with the "checkboxes" form control (or if I does I know how to use it!)

As a work around use the checkbox type instead:

$form['report_group']['selectall'] = array(
  '#title' =&gt; 'Check All',
  '#type' =&gt; 'checkbox',
  '#default_value' =&gt; 0,
);

$boxes = array(1 =&gt; 'one', 2 =&gt; 'two', 3 =&gt; 'three', 4 =&gt; 'four', 5 =&gt; 'five');

foreach($boxes as $key =&gt; $val) {

  $form['report_group']['box_'.$key] = array(
    '#type' =&gt; 'checkbox',
    '#title' =&gt; $val,
    '#return_value' =&gt; $key,
    '#states' =&gt; array(
      'checked' =&gt; array(
        ':input[name="selectall"]' =&gt; array('checked' =&gt; TRUE),
      ),
    ),
  );
}


Your selector was also wrong. This is a jQuery selector so I find it easiest to use firebug to figure out what it should be and test if it's working.