diff --git a/entityreference_prepopulate.module b/entityreference_prepopulate.module index 06c7ebb2954188499811450c45c1b0bf222f6ae4..f7653b965db1e9c9af67c17e3eb24e6768437c0b 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') {