Trouble with Form API and #states
You forgot about unique keys in your form elements. Here is a working example:

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

  // your size options
  $options = array('small', 'medium', 'big');

  $form['checkboxes'] = array(
    '#type' =&gt; 'fieldset',
  );

  foreach ($options as $size) {

    $form['checkboxes'][$size . '_checkbox'] = array(
      '#type' =&gt; 'checkbox', 
      '#title' =&gt; t($size . ' size'),
    );

    $form[$size . '_field'] = array(
      '#type' =&gt; 'fieldset', 
      '#title' =&gt; t($size . ' size'), 
      '#collapsible' =&gt; TRUE,
      '#collapsed' =&gt; TRUE,
      '#states' =&gt; array(
        'expanded' =&gt; array(
          ':input[name="' . $size. '_checkbox"]' =&gt; array('checked' =&gt; TRUE),
        ),
      ),
    );

    $form[$size . '_field']['some_info'] = array(
      '#type' =&gt; 'textarea', 
      '#title' =&gt; t($size . ' size textarea'),
    );
  }
  return $form;
}


Result: