Use drupal #states to check a radio I would like to translate some jquery .change functionality to use #states in the form api. 

var radio1 = jQuery('input:radio[name=radio_1]');
var radio2 = jQuery('input:radio[name=radio_2]');

radio1.change(function() {
if (radio1.filter(':checked').val() == 0) {
  radio2[1].checked = true;
}
else {
  radio2[0].checked = true;
}
});

radio2.change(function() {
if (radio2.filter(':checked').val() == 0) {
  radio1[1].checked = true;
}
else {
  radio1[0].checked = true;
}
});


Logic:
If radio1 value 0 is selected then radio2 value 1 will be selected.
If radio1 value 1 is selected then radio2 value 0 will be selected.
if radio2 value 0 is selected then radio1 value 1 will be selected.
if radio2 value 1 is selected then radio1 value 0 will be selected.  

Looking at form_example_states_form() shows that the syntax is:

'#states' =&gt; array(
  'action_to_take_on_this_form_element' =&gt; array(
    'jquery_selector_for_another_element' =&gt; array(
      'condition_type' =&gt; value,
    ),
  ),
),


What's missing for me is "action_to_take_on_this_form_element". I don't know how to select value 0 or 1 of the radio button; all I have in terms of viable options is checked/unchecked (see drupal_process_states() for a list).

What I currently have

'#states' =&gt; array(
  'checked' =&gt; array(
    ':input[name="radio_2"]' =&gt; array(
      'value' =&gt; 0,
    ),
  ),
  'unchecked' =&gt; array(
    ':input[name="radio_2"]' =&gt; array(
      'value' =&gt; 1,
    ),
  ),
),


and this doesn't seem to work. I need something like checked[0] in order to select the value 0 radio button.

Edit: Here is the working code. Would like to not use inline js.

function your_form(&amp;$form, $form_state) {
  $form['radios1'] = array(
    '#type' =&gt; 'radios',
    '#title' =&gt; 'Radios 1',
    '#options' =&gt; array(
      0 =&gt; 'zero',
      1 =&gt; 'one',
    ),
    '#default_value' =&gt; 0,
  );

  $form['radios2'] = array(
    '#type' =&gt; 'radios',
    '#title' =&gt; 'Radios 2',
    '#options' =&gt; array(
      0 =&gt; 'zero',
      1 =&gt; 'one',
    ),
    '#default_value' =&gt; 1,
  );

  $form['#attached']['js'][] = array(
    'data' =&gt; "var radio1 = jQuery('input:radio[name=radios1]');
var radio2 = jQuery('input:radio[name=radios2]');

radio1.change(function() {
if (radio1.filter(':checked').val() == 0) {
  radio2[1].checked = true;
}
else {
  radio2[0].checked = true;
}
});

radio2.change(function() {
if (radio2.filter(':checked').val() == 0) {
  radio1[1].checked = true;
}
else {
  radio1[0].checked = true;
}
});",
    'type' =&gt; 'inline',
  );

  return $form;
}


Demo video: https://www.youtube.com/watch?v=lXfMFaTTVes
You can use the form_api #after_build property to set a callback where you can manipulate the individual radio button elements (not the grouped "radios" element).

function your_form(&amp;$form, $form_state) {
  $form['radios1'] = array(
    '#type' =&gt; 'radios',
    '#title' =&gt; 'Radios 1',
    '#options' =&gt; array(
      0 =&gt; 'zero',
      1 =&gt; 'one',
    )
  );

  $form['radios2'] = array(
    '#type' =&gt; 'radios',
    '#title' =&gt; 'Radios 2',
    '#options' =&gt; array(
      0 =&gt; 'zero',
      1 =&gt; 'one',
    )
  );

  $form['#after_build'] = array('your_form_after_build_function');

  return $form;
}

function your_form_after_build_function($form) {
  $form['radios1'][0]['#states'] = array(
    'checked' =&gt; array(
      ':input[name="radios2"]' =&gt; array('value' =&gt; 1),
    ),
  );

  $form['radios1'][1]['#states'] = array(
    'checked' =&gt; array(
      ':input[name="radios2"]' =&gt; array('value' =&gt; 0),
    ),
  );

  $form['radios2'][0]['#states'] = array(
    'checked' =&gt; array(
      ':input[name="radios1"]' =&gt; array('value' =&gt; 1),
    ),
  );

  $form['radios2'][1]['#states'] = array(
    'checked' =&gt; array(
      ':input[name="radios1"]' =&gt; array('value' =&gt; 0),
    ),
  );

  return $form;
}