When auto_entitylabel_form_alter() executes when using the Inline Entity Form widget for entity reference fields with the 'Add new [entity type]' option, when auto_entitylable_form_alter() is called, it get invoked for the parent entity, and not for the 'new' entity being referenced, which means that the auto label processing on the form is not performed.
While there has been work in #1787838: Support Automatic Entity Label module to fix this in IEF proper, I actually have realized that if auto entity label also used hook_field_attach_form() to do its processing, then it covers all cases without much changes.
Comment | File | Size | Author |
---|---|---|---|
#6 | 1980652-autoentitylabel-field-attach-submit.patch | 704 bytes | Dave Reid |
#1 | 1980652-auto-entitylabel-field-attach-form-alter.patch | 1.42 KB | Dave Reid |
Comments
Comment #1
Dave ReidThe following patch has worked well for our install.
Comment #2
bforchhammer CreditAttribution: bforchhammer commentedOk, I don't see any problems with this. Committed and pushed!
Comment #4
johnstav CreditAttribution: johnstav commentedEntity label appears as %AutoEntityLabel% when:
- Add an entity via the inline entity widget
- Save the added entity
- Don't save the parent entity
- Edit the added entity
- Save the added entity again.
Comment #5
bforchhammer CreditAttribution: bforchhammer commented@johnstav: sorry, I have no experience with the inline entity widget. Maybe you can try posting your issue in the IEW queue (possibly in #1787838: Support Automatic Entity Label module); if you find that there's something specific that should be changed in the AEL module, please create a new issue. (In that case a patch would be awesome!)
Comment #6
Dave ReidActually I confirmed the bug in #4. This needs one small follow-up to create the auto-label using hook_field_attach_submit().
Comment #7
bforchhammer CreditAttribution: bforchhammer commentedOkay, committed #6. :)
Comment #9
adam1 CreditAttribution: adam1 commentedUsing latest stable version 7.x-1.2 with patch #6 or latest dev version 7.x-1.2+6-dev, a problem occurs:
when adding a new entity via the inline_entity widget, the auto-entity-title works perfect, but when editing an existent entity inline, the auto-entity-title doesn't work, the title is shown as "%AutoEntityLabel%".
Comment #10
Anonymous (not verified) CreditAttribution: Anonymous commentedUsing the latest dev versions of Inline Entity Form & Automatic Entity Label, which includes the patch committed at #7, I continue to experience the same problem described at #4:
Marking this as 'needs work', since Automatic Entity label does not seem to work fully with Inline Entity Form.
Comment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedApplying the patch in comment #2 at https://www.drupal.org/node/2329729 solved this problem for me.
Comment #12
bforchhammer CreditAttribution: bforchhammer commentedI have committed the patch in #2329729: ECK: Autolabel set on insert; reset to %AutoEntityLabel% on subsquent saves., so setting back as fixed.
Comment #13
nithinkolekar CreditAttribution: nithinkolekar commentedI am not sure whether this has to be done in #2212861: title autogenerate doesn't always copy updated parent entity title to child commerce products or is it the AEL
When using two bundles like Book author, Books where Book author is parent entity having entityreference field which point to Book entity with Inline Entity Form as widget.
For setting title of Book using AEL (Automatically generate the label and hide the label field) following token is used
[node:field-book-name][node:field-book-ref:0:title]
but title from parent node ie Book author title is not injected.If it is not related to AEL then it can be closed again.
Comment #14
milos.kroulik CreditAttribution: milos.kroulik commentedI can confirm, that patch commited in #12 works fine. Can you create separate issue for your problem, please? Setting this back to fixed.
Comment #15
elvisronn CreditAttribution: elvisronn as a volunteer commentedPatch #6 worked for me. Thanks.
Comment #16
trumanru CreditAttribution: trumanru commentedI see patch #12 in the code of this module. But in my case the problem resolved only after I've applied patch #6.
I think #6 should be included in the module.
Comment #17
Donit CreditAttribution: Donit commentedTrue, #6 isn't committed. I also get hunks
and still see %AutoEntityLabel% via Inline Entity Form.
Comment #18
julien.reulos CreditAttribution: julien.reulos commentedI also confirm it is only working by adding the patch from #6.
Comment #19
DakwamineFun fact: I have tried to apply this patch on the D8 version of auto_entitylabel with composer. The patch applied well but, obviously, was not working. For D8 websites, please check #2905230: Title displayed as %AutoEntityLabel% after saving via Inline Entity Form, comment #6.
Comment #20
tory-w CreditAttribution: tory-w as a volunteer commentedConfirming patch #6 works.