I've no idea if this is ECK doing it wrong, or auto_entitylabel making an assumption it shouldn't. But, when an eck entity is first saved it gets an auto_entityautolabel, however on subsequent saves this gets reverted to '%AutoEntityLabel%'.
What is happening is:-
auto_entitylabel in its hook_field_attach_submit() is setting the title (both on insert and update).
The hook was triggered from eck__entity__form_submit() which goes on to If we find a value set for a property lets just set it.
set the title to what it was in the form which is '%AutoEntityLabel%'. It is set to this both on insert and update - I'm not sure why it's got that value on update when it could be the previously set title?
On insert it works because auto_entitylabel in its hook_entity_insert makes the label anew, because auto_entitylabel_is_needed() is called with the $reset switch true.
On update the calls to auto_entitylabel_is_needed() don't have $reset, so because a label has been set it does not do it again.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | eck_autolabel_is_needed_check-2329729-11.patch | 3.72 KB | cravecode |
| #7 | eck_autolabel_is_needed_check-2329729-7.patch | 1.97 KB | cravecode |
| #2 | auto_entitylabel-fix_for_eck_or_ief-2329729-02.patch | 685 bytes | pdcrane |
| #1 | 2329729-01-auto_entitylabel_eck.patch | 526 bytes | ekes |
Comments
Comment #1
ekes commentedJust to make the point, my work-around, if anyone needs it till someone can work out how to fix this properly, just forces update on presave.
Comment #2
pdcrane commentedI was having this same issue with Inline Entity Forms, but I patched it differently. See attached.
Also, this is my very first patch file following the directions here: https://www.drupal.org/node/707484
Hopefully I didn't screw it up =P
Comment #3
Anonymous (not verified) commentedApplying the patch in #2 solved the issue for me described at https://www.drupal.org/node/1980652#comment-9290785, whereas the patch in #1 didn't.
Marking this as 'needs review'.
Comment #4
cravecode commentedPatch #2 worked for me as well.
(My scenario was related to the Inline Entity Form problem)
Comment #5
cravecode commentedIt may be a better solution to check for reset or "%AutoEntityLabel%" instead of always setting reset to true. That's just a suggestion though, I'm fine with how patch #2 currently works.
Comment #6
bforchhammer commentedThat sounds like a good idea. I would rather not add special cases for specific modules... ;-)
Comment #7
cravecode commentedI'm submitting my patch that checks for both empty and "%AutoEntityLabel%". Because I needed to use some values from the $settings array, I had to change the order of the logic. With that in mind, i chose to make the steps pretty verbose for easier reading over fewer lines of code.
@broxen, thank you so much for creating the issue related to inline entity forms. Had I not found that issue, it could have taken me a while to figure out what was going on or I'd have ditch the idea of using this module all together.
@bforchhammer, this module is fantastic! Thanks for your work!
Comment #8
bforchhammer commentedThanks for your patch, looks good overall!
A few minor things:
Line too long (>80). Maybe just move @param descriptions into new line... :)
Let's put the
%AutoEntityLabel%string into a constant at the top of the file.Line too long :)
Comment #9
bforchhammer commentedThis is actually the entity "type"; the "bundle" usually refers to things like node types (e.g. page, article)
@broxen, @ekes: can you guys give the patch a go and confirm that this solves the problem for you as well?
Comment #10
cravecode commented@bforchhammer Thanks for the feedback! I'll post a updated patch soon. Are you sure $entity_type was just the actual type? I'm almost sure I remember it being the bundle. I'll verify when I update the patch.
I was going to suggest moving "%AutoEntityLabel%" into a constant but I figured it was out of scope for this issue. Sounds like you want it, so I'll include the new constant with my next patch.
Comment #11
cravecode commentedI was wrong, $entity_type is just the type, not the bundle :)
Attached is the updated patch.
Comment #12
bforchhammer commentedWorks for me. Thanks!
Comment #14
kamenrs commentedI've downloaded the last dev version form Drupal.org with this patch committed and the problem is still present.
After re-saving a commerce product the entity label is set to %AutoEntityLabel% (attribute).
CORRECTION: Sorry about that - actually it works as it should. It should be my mistake. Thanks a lot for your work.
Comment #15
cravecode commented@kamenrs, I can't reproduce that. Here is what I've done so far:
admin/structure/types/manage/product-display/fields/field_productadmin/commerce/config/product-variation-types/product/auto_labeland selected "Automatically generate the label and hide the label field"Have you tried clearing your caches? Is there a different process you are taking than I've documented?
Thanks for the feedback!
Comment #16
kamenrs commented@cravecode
Thank you very much for your lightning fast reply.
I apologize for this comment. It should have been my failure.
After some more tries I get the expected result. Everything works as it should. Really sorry about wasting your time.
Thanks for the time and efforts. I don't deserve them.
Thanks a ton for your great work. Please, excuse me.
Comment #17
cravecode commented@kamenrs no problem! I'm working on a e-commerce site an just downloaded Commerce Kickstart when I saw your comment come in. I figured it would only take a minute to document my steps so why not help someone in the process.
Glad to hear it's working, the more testing, the better! Good luck!