diff --git a/entityreference.module b/entityreference.module index 2327e9b..eb57268 100644 --- a/entityreference.module +++ b/entityreference.module @@ -114,11 +114,22 @@ function entityreference_field_validate($entity_type, $entity, $field, $instance } /** - * Implements hook_field_presave(). + * Implements hook_field_insert(). * * Adds the target type to the field data structure when saving. */ -function entityreference_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) { +function entityreference_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) { + foreach ($items as $delta => $item) { + $items[$delta]['target_type'] = $field['settings']['target_type']; + } +} + +/** + * Implements hook_field_update(). + * + * Adds the target type to the field data structure when saving. + */ +function entityreference_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) { foreach ($items as $delta => $item) { $items[$delta]['target_type'] = $field['settings']['target_type']; }