Move fields into fieldset with field_collection module doesn't work I have a node, inside this node I have a field_collection with one checkbox and 2 fields inside it. I want to move these two fields inside a fieldset to show/hide entire fieldset depending of the checkbox value.

function mymodule_form_testtype_node_form_alter(&amp;$form, &amp;$form_state, $form_id) {    
    $form['field_test_collection']['und'][0]['surround_fieldset'] = array(
        '#type' =&gt; 'fieldset',
        '#title' =&gt; t('Sorround fieldset'),
        '#tree' =&gt; FALSE,
    );
    $form['field_test_collection']['#tree'] = FALSE;
    $form['field_test_collection']['und'][0]['surround_fieldset']['field_collection_first'] = $form['field_test_collection']['und'][0]['field_collection_first'];
    $form['field_test_collection']['und'][0]['surround_fieldset']['field_collection_second'] = $form['field_test_collection']['und'][0]['field_collection_second'];
}


But when I try to submit the form these two values are not saved. I tried to remove the original fields using 

unset($form['field_test_collection']['und'][0]['field_collection_first']);


or hide them with

$form['field_test_collection']['und'][0]['field_collection_first']['#access'] = 0;


I also tried the "cheat" to move back these two fields in the validate function

function mymodule_article_form_testtype_node_form_validate(&amp;$form, &amp;$form_state) {
    $form_state['values']['field_test_collection']['und'][0]['field_collection_first'] = $form_state['values']['field_test_collection']['und'][0]['surround_fieldset']['field_collection_first'];
    $form_state['values']['field_test_collection']['und'][0]['field_collection_second'] = $form_state['values']['field_test_collection']['und'][0]['surround_fieldset']['field_collection_second'];
    unset($form_state['values']['field_test_collection']['und'][0]['surround_fieldset']);   

    $form['field_test_collection']['und'][0]['field_collection_first'] = $form['field_test_collection']['und'][0]['surround_fieldset']['field_collection_first'];
    $form['field_test_collection']['und'][0]['field_collection_second'] = $form['field_test_collection']['und'][0]['surround_fieldset']['field_collection_second'];
    unset($form['field_test_collection']['und'][0]['surround_fieldset']);
    $form['field_test_collection']['und'][0]['field_collection_first']['#access'] = 1;
    $form['field_test_collection']['und'][0]['field_collection_second']['#access']  = 1;
}


With a dpm($form_state) in the submit function I can see correct values in their places, but after it they're not saved.

Any idea?
Thank you
I found the solution. It seems values from fields inside the field_collections are not managed as other Drupal form values.

This is the code to achieve the result:

function mymodule_form_testtype_node_form_alter(&amp;$form, &amp;$form_state, $form_id) {    
    $form['field_test_collection']['und'][0]['surround_fieldset'] = array(
        '#type' =&gt; 'fieldset',
        '#title' =&gt; t('Sorround fieldset'),
    );
    $form['field_test_collection']['und'][0]['surround_fieldset']['field_collection_first'] = $form['field_test_collection']['und'][0]['field_collection_first'];
    unset($form['field_test_collection']['und'][0]['field_collection_first']);
    $form['field_test_collection']['und'][0]['surround_fieldset']['field_collection_second'] = $form['field_test_collection']['und'][0]['field_collection_second'];
    unset($form['field_test_collection']['und'][0]['field_collection_second']);
    $form['#submit'][] = 'mymodule_node_form_submit';
}

function mymodule_node_form_submit($form, &amp;form_state) {
    $form_state['field']['field_test_collection']['und']['entity'][0]-&gt;field_collection_first['und'][0]['value']=$form_state['values']['field_test_collection']['und'][0]['surround_fieldset']['field_collection_first']['und'][0]['value']; 
    $form_state['field']['field_test_collection']['und']['entity'][0]-&gt;field_collection_second['und'][0]['value']=$form_state['values']['field_test_collection']['und'][0]['surround_fieldset']['field_collection_second']['und'][0]['value'];
}