summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmitaibu2013-06-06 05:46:37 (GMT)
committer Amitaibu2013-06-06 05:46:37 (GMT)
commitc96b0afca195ba5f5e939b209e6aa536d79413fd (patch)
tree662b59762b533bce6941ee6b0de9584a4c19fc61
parente2c28119661d0406f72616249a3e5e893d3f789b (diff)
Issue #2007746 by Amitaibu, rbrandon: use hook_field_access() to hide fields of exiting entities
-rw-r--r--entityreference_prepopulate.module10
1 files changed, 7 insertions, 3 deletions
diff --git a/entityreference_prepopulate.module b/entityreference_prepopulate.module
index 06c7ebb..f7653b9 100644
--- a/entityreference_prepopulate.module
+++ b/entityreference_prepopulate.module
@@ -150,12 +150,16 @@ function entityreference_prepopulate_field_access($op, $field, $entity_type, $en
return;
}
- if ($id) {
- // Entity is already saved. Return FALSE if we need to hide the field,
- // otherwise ignore.
+ if ($id && empty($entity->is_new)) {
return $settings['action'] == 'hide' ? FALSE : NULL;
}
+ if ($settings['action'] == 'hide') {
+ // If entity is already saved and not just inserted, deny access, otherwise
+ // ignore.
+ return $id && empty($entity->is_new) ? FALSE : NULL;
+ }
+
$ids = entityreference_prepopulate_get_values($field, $instance);
if (!$ids && $settings['fallback'] == 'hide') {