Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The "Hide" action in the current dev version causes populated fields to be hidden on the node edit form, even if the "Apply action on edit" option is not checked.
The "Disable" action doesn't seem to suffer with the same problem.
This issue seems to be a result of the code committed in #2007746: use hook_field_access() to hide fields of exiting entities, which doesn't appear to include a condition accounting for $settings['action_on_edit']
.
Comment | File | Size | Author |
---|---|---|---|
#4 | entityreference_propopulate-ignored-setting-2024151-4.patch | 3.42 KB | RoySegall |
#3 | entityreference_propopulate-ignored-setting-2024151.patch | 1.6 KB | morbiD |
Comments
Comment #1
amitaibuCan you provide a patch? :)
Comment #2
morbiD CreditAttribution: morbiD commentedYeah, I'm working on it, but I'm actually struggling to understand some of the logic in the code.
Specifically, in this snippet:
It seems to me that the second
if
condition is only evaluated if the first one evaluates to FALSE, and if the first one does evaluate to FALSE, thenreturn $id && empty($entity->is_new) ? FALSE : NULL;
must also evaluate to FALSE and can only ever return NULL. If I'm following it correctly, that's just redundant code...Also, I don't get why the following snippet is evaluated last in the function:
Surely if there are no prepopulate values passed to the form and we're checking the fallback behaviour, then there is no reason to have carried out the previous checks as though prepopulate values had been passed?
I'll post a patch later if I manage to figure it all out.
Comment #3
morbiD CreditAttribution: morbiD commentedOk, I *think* I've got it all figured out, so here's a patch.
It seems to work correctly for all combinations of action and fallback settings, but I haven't tested extensively.
Comment #4
RoySegall CreditAttribution: RoySegall commentedI'm attaching a patch that handle the problem - when the user checked the "apply on edit" check box and i fixed the tests so they could verify that the feature work as expected.
Comment #5
amitaibuCommitted, thanks.