diff --git a/field_collection.info.inc b/field_collection.info.inc index 03c961a..db47f45 100644 --- a/field_collection.info.inc +++ b/field_collection.info.inc @@ -24,6 +24,24 @@ class FieldCollectionItemMetadataController extends EntityDefaultMetadataControl 'required' => TRUE, ); + // Also add type-specific host entity references for all entity types that + // have at least one field collection field. + $entity_info = entity_get_info(); + foreach (field_read_fields(array('type' => 'field_collection')) as $field_name => $field) { + $field_info = field_info_field($field_name); + $entity_types = array_keys($field_info['bundles']); + foreach ($entity_types as $entity_type) { + $args = array('@type' => $entity_info[$entity_type]['label']); + $info['field_collection_item']['bundles'][$field_name]['properties']["host_entity_{$entity_type}"] = array( + 'label' => t('Host entity (@type)', $args), + 'type' => $entity_type, + 'description' => t('The @type containing the field collection field (empty if this field collection is attached to an item of a different type).', $args), + 'getter callback' => 'field_collection_item_get_host_entity', + 'computed' => TRUE, + ); + } + } + return $info; }