diff --git a/field_collection.module b/field_collection.module index 888e626..896ca35 100644 --- a/field_collection.module +++ b/field_collection.module @@ -963,15 +963,8 @@ function field_collection_field_presave($host_entity_type, $host_entity, $field, if ($entity = field_collection_field_get_entity($item)) { - if (!empty($entity->is_new)) { - $entity->setHostEntity($host_entity_type, $host_entity, $langcode, FALSE); - } - else { - $entity->updateHostEntity($host_entity); - } - // If the host entity is saved as new revision, do the same for the item. - if (!empty($host_entity->revision)) { + if (!empty($host_entity->revision) || !empty($host_entity->is_new_revision)) { $entity->revision = TRUE; $is_default = entity_revision_is_default($host_entity_type, $host_entity); // If an entity type does not support saving non-default entities, @@ -981,6 +974,14 @@ function field_collection_field_presave($host_entity_type, $host_entity, $field, $entity->archived = FALSE; } } + + if (!empty($entity->is_new)) { + $entity->setHostEntity($host_entity_type, $host_entity, $langcode, FALSE); + } + else { + $entity->updateHostEntity($host_entity); + } + $entity->save(TRUE); $item = array(