Problem/Motivation
Provide hooks for modules to react when inline entities are saved or deleted and open the way to easily integrate IEF in complex environments, when using contrib modules for content access and permission handling(e.g. Group module).
This feature was already requested several times and requires only minor modifications:
#2976376: Inline editing in the group context
#3190079: IEF and Group integration
#3144853: Group and IEF Integration
Proposed resolution
Provide three new hooks for modules to react on:
- after an inline entity is saved
- before an entity is deleted
- after the create bundles list is populated
Remaining tasks
Create a patch
User interface changes
None
API changes
Yes
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 3197629-18.patch | 5.92 KB | jordik |
Issue fork inline_entity_form-3197629
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
jordik commentedComment #3
jordik commentedThe patch above adds three new hooks to the IEF API :
Comment #4
jordik commentedAdd the inline_entity_form widget to the context.
Comment #5
jordik commentedRe-roll of patch from #4 to latest dev (Apr 15 2021, rc9).
Needs review.
Comment #6
rp7 commentedSounds like a good idea IMO. Thank you.
Two questions:
Comment #7
jordik commentedThis means that one can not modify the entity object in the hook, only the $form_state object.
Yes, but it is up to the maintainers to decide this.
Comment #8
odai atiehI updated the latest patch to fix the warning
($form_state) must be passed by reference.Comment #10
podarok#8 is in
tnx
Comment #12
geek-merlinBulk reopen.
Comment #13
geek-merlinShort review: I like the idea, but this needs some work. If someone is still wanting to work on this, i can give a full review.
Comment #14
geek-merlinComment #15
jordik commentedI can work on this.
Comment #16
jordik commentedRe-rolled the patch for 3.x.-dev.
There was a change in the function determineBundle introduced in #3358281: Wrong bundle form is displayed if user has permissions to create only one of the available bundles.
It is now using $this->getCreateBundles() instead of $this->getTargetBundles() to solve the issue of user permissions to create certain bundles to be respected. Passed $context as variable to the function to allow for the API call.
Works now as expected. Please review.
Comment #18
hocuYou are lifesavers!
I tested the
inline_entity_form_entity_savehook so far, and everything works great. I took the liberty of creating an issue fork, just to clean up some warnings raised by PhpStorm (nitpicking mode on 🙄).Once I test the other hooks, I will update the status to RTBC.
Comment #20
hocuTested with latest D10.4. All good, thank you. Converting to RTBC now.