Embedded field collection not saving with node using conditional fields Why is the field collection portion of my node form not saving?  I am working on a form that collects travel plans from staff members.  As part of this I have a nested field collection to collect itineraries and legs within those itineraries.

to give you a rough description of the related fields:



This is not all the fields on the form, but this should give the idea of the structure.  I fill out the form, save, and the saved node contains all the other information, but nothing that was in the field collections shows up.

Since country is an additional module, I tried deleting the country field, but that didn't solve anything.  I'm also using the conditional fields module extensively to show and hide other fields though the fields in the field collection are not affected by this.

Finally I'm using a custom module called missions (UPDATE:  I've disabled the module, and the problem persists, so it seems not to have been the form_alter) to show one field in the field_mr_fc_legs field collection when field_mr_home_leave is checked.  The entire code of which can be found below:

/**
 * Implements hook_form_BASE_FORM_ID_alter().
 */
function missions_form_mission_request_node_form_alter(&amp;$form, &amp;$form_state, $form_id)
{
  $form['body'][LANGUAGE_NONE][0] += array(
    '#placeholder' =&gt; t('Day 1

*  Activity 1
*  Activity 2

Day 2'),
  );
  $form['field_mr_home_leave'][LANGUAGE_NONE]['#ajax'] = array(
    'callback' =&gt; 'missions_hide_home_leave_toggle',
    'wrapper' =&gt; 'itinerary-section',
  );
  $form['field_mr_fc_itineraries']['#prefix'] = '&lt;div id="itinerary-section"&gt;';
  $form['field_mr_fc_itineraries']['#suffix'] = '&lt;/div&gt;';
  if ((!empty($form_state['complete form']['field_mr_home_leave']['und']['#value']) &amp;&amp; $form_state['complete form']['field_mr_home_leave']['und']['#value'] == 1) || (empty($form_state['values']['field_mr_home_leave']) &amp;&amp; $form['field_mr_home_leave'][LANGUAGE_NONE]['#default_value'] == 1)) {
    $home_leave_toggle_access = true;
  } else {
    $home_leave_toggle_access = false;
  }
  foreach ($form['field_mr_fc_itineraries'][LANGUAGE_NONE] as $key =&gt; &amp;$itinerary) {
    if (is_integer($key)) {
      foreach ($itinerary['field_mr_fc_legs'][LANGUAGE_NONE] as $key =&gt; &amp;$leg) {
        if (is_integer($key)) {
          $leg['field_mr_fc_leg_home_leave']['#access'] = $home_leave_toggle_access;
        }
      }
    }
  }

}

function missions_hide_home_leave_toggle($form, $form_state) {
  return $form['field_mr_fc_itineraries'];
}


What is the likely cause of this?  The Recent log messages report shows just that the node was updated.  Is it my module?  Is it nested field collections?

What I've tried


I disabled my module, and it didn't make a difference
I removed the nested field collection and it didn't make a difference.
I removed the country field to verify that it wasn't the country module causing the issue.
The issue seems to be caused by conditional fields, when I disable that, the form saves properly.
I think, it's because field collection is not part of the node, field collection is a separate entity, which needs to be saved separately. 

I once had to add up some number fields and save the value in a field collection field on hook_node_presave

/**
 * Implements hook_node_presave().
 */
function MYMODULE_node_presave($node)
{
  foreach ($node-&gt;field_collection_field[LANGUAGE_NONE] as $key =&gt; $value) {
    $fc_id = $node-&gt;field_collection_field[LANGUAGE_NONE][$key]['value'];
    $field_collection_item = entity_load_single('field_collection_item', $fc_id);
    $field_collection_item-&gt;save(TRUE);
  }
}