diff --git a/README.txt b/README.txt index 3f1dee3..17c495a 100644 --- a/README.txt +++ b/README.txt @@ -13,11 +13,11 @@ field collection item may also be viewed and edited separately. ------ * Add a field collection field to any entity, e.g. to a node. For that use the - the usual "Manage fields" interface provided by the "field ui" module. - e.g. "Admin -> Structure-> Content types -> Article -> Manage fields". + the usual "Manage fields" interface provided by the "field ui" module. + e.g. "Admin -> Structure-> Content types -> Article -> Manage fields". * Then go to "Admin -> Structure-> Field collection" to define some fields for - the created field collection. + the created field collection. * By the default, the field collection is not shown during editing of the host entity. However, some links for adding, editing or deleting field collection diff --git a/field_collection.entity.inc b/field_collection.entity.inc index 8b3a034..0479b59 100644 --- a/field_collection.entity.inc +++ b/field_collection.entity.inc @@ -411,7 +411,7 @@ class FieldCollectionItemEntity extends Entity { public function save($skip_host_save = FALSE) { // Make sure we have a host entity during creation. if (!empty($this->is_new) && !(isset($this->hostEntityId) || isset($this->hostEntity) || isset($this->hostEntityRevisionId))) { - throw new Exception('Unable to create a field collection item without a given host entity.'); + throw new Exception("Unable to create a field collection item without a given host entity."); } // Copy the values of translatable fields for a new field collection item. @@ -466,10 +466,15 @@ class FieldCollectionItemEntity extends Entity { * Language code to copy the text from. */ public function copyTranslations($source_language = NULL) { - $host_et_handler = entity_translation_get_handler($this->hostEntityType(), $this->hostEntity()); - if (empty($host_et_handler)) { + // Get a handler for Entity Translation if there is one. + $host_et_handler = NULL; + if (module_exists('entity_translation')) { + $host_et_handler = entity_translation_get_handler($this->hostEntityType(), $this->hostEntity()); + } + if (is_null($host_et_handler)) { return; } + $host_languages = array_keys($host_et_handler->getTranslations()->data); if (empty($host_languages)) { $host_languages = array(entity_language($this->hostEntityType(), $this->hostEntity()));