How to simulate radio button functionality within a form I have a form which has 3 radio buttons, each providing a fieldset.

o Choice 1
  Fieldset of options v
o Choice 2
  Fieldset of options v
o Choice 3
  Fieldset of options v


In order to achieve this, the three radios are each individual radio buttons, and the fieldset for each is enabled when the radio is checked.

The problem, of course, is that once checked, checking one of the other radios doesn't uncheck the original, because they are different fields. I could use #states to simulate radio behavior, clearing one when another is selected, but I don't believe that will work. If I set Option2 to clear if Option1 is checked:
  Checking Option2, then checking Option1 will clear Option2, great
  Trying to check Option2 again will leave it unchecked, because the test of whether Option1 is checked will be true

I tried this setting for two of them:

  '#states' =&gt; array(
    'unchecked' =&gt; array(
      ':input[name="*theOtherOption*"]' =&gt; array('checked' =&gt; TRUE),
    ),


What happens is the behavior works for the first click of each radio button, clicking 1 turns off 2, clicking 2 turns off 1, and then it stops working and I end up with both clicked.
you should study the Ajax examples module you can follow the examples estructures to build you own code.
 After doing that your code should look somethink like this:

function test_code_radios_callback($form, $form_state) {
  return $form['radios_fieldset'];
}


function test_code_form($form, &amp;$form_state) {

    $options = array(
        'Name'=&gt;t('Name'),
        'Nickname'=&gt;t('Nickname'),
        'Lastname'=&gt;t('Lastname')
        );

    $form['alias'] = array(
    '#type' =&gt; 'radios',
    '#title' =&gt; 'Choose your alias',
    '#options' =&gt; $options,
    '#default_value' =&gt; isset($form_state['values']['alias']) ? $form_state['values']['alias'] : '',
    '#ajax' =&gt; array(
      'callback' =&gt; 'test_code_autotextfields_callback',
      'wrapper' =&gt; 'textfields',
      'effect' =&gt; 'fade',
        ),
  );

    $form['textfields'] = array(
    '#title' =&gt; t("Your Alias"),
    '#prefix' =&gt; '&lt;div id="textfields"&gt;',
    '#suffix' =&gt; '&lt;/div&gt;',
    '#type' =&gt; 'fieldset',
    '#description' =&gt; t('Write your alias here'),
  );


    if (!empty($form_state['values']['alias']) &amp;&amp; $form_state['values']['alias']) {
    $value = array();
    $value = $form_state['values']['alias'];

    foreach($value as $item) {
    $name = $item;
    }

      $form['textfields']['$value'] = array(
      '#type' =&gt; 'textfield',
      '#title' =&gt; $value,
      );

  }

  return $form;
}
function test_code_autotextfields_callback($form, $form_state) {
  return $form['textfields'];
}


I tested and it's working as i understood you need it. Tell us how it went. Have a good coding!.