Problem/Motivation
When I select "Automatically generate the label and hide the label field"
and configure token : 'R-[node:nid]_[current-date:html_year' it works fine,
however when I select
"Automatically generate the label if the label field is left empty" with the same token R-[node:nid]_[current-date:html_year'
node:nid won't work and create R-_2021 instead
Is it possible to fix it? I need to migrate nids from the old site and cannot be changed, hence title will stay :R-[old_nid] which is fine, but when I create new content type it won't use node:nid. just already mentioned R-_2021
Steps to reproduce
-already mentioned
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#14 | 3205865-test-only.patch | 1021 bytes | kksandr |
Issue fork auto_entitylabel-3205865
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
splash112 CreditAttribution: splash112 commentedDid you find a solution to this? My entity tokens suddenly stopped working on 1 entity...
Comment #3
splash112 CreditAttribution: splash112 commentedNoticed I had switched on Token CUSTOM DISPLAY SETTINGS. Switching that off again filled the entity label nicely.
Weird, as the config was exported from staging where it worked perfectly.
Comment #4
coaston CreditAttribution: coaston commentedHm, not sure i understand, does it mean you find a workaround?
Comment #5
splash112 CreditAttribution: splash112 commentedCould be a bug, but would need to look into that. Noticed that node tokens for this module worked in 1 content type but not in the other.
Switching off custom display type for tokens at /admin/structure/types/manage/***/display fixed it.
Comment #6
ivnish CreditAttribution: ivnish commentedDuplicate of https://www.drupal.org/project/auto_entitylabel/issues/1445124
Comment #7
coaston CreditAttribution: coaston commentedIvnish - how this can be a duplicate if this is related to d8/9 version and you posted d7 link?
Please reopen it - still waiting for the patch!
Comment #8
coaston CreditAttribution: coaston commentedComment #9
kksandr CreditAttribution: kksandr commentedHello, I faced the same problem.
The problem is that the module, if possible, populates the label in the presave hook where the entity ID is not yet available. And after that, the label is no longer considered empty and is not updated.
My solution is to add the ability to force the label to be re-save. To do this, a temporary label value is written to the label for new entities that do not have an identifier, which will also be considered empty for the next save. The new option in the form is called "Generate by resaving".
Comment #10
kksandr CreditAttribution: kksandr commentedComment #11
marcoliverI just tested the patch from #9 and it works fine. Seems like a good solution!
Marking as RTBC.
Comment #12
dqdApart from some minor trouble in the patch which needs to be corrected/clarified, this issue is far behind and we need more reports if this issue is still reproducable at latest dev and latest stable release, which is 2 years younger than this issue here.
Additionally the patch needs to be rerolled then for latest dev if the issue still persist. Than we can think about a backport if required for circumstances where older versions of this project are mandatory.
Comment #14
kksandr CreditAttribution: kksandr commentedThe solution you quote is already used in this module. The patch just moves this string constant into a class constant for easy reuse.
This issue is still relevant, I have opened a merge request for the current version of the module.
I also added a test that reproduces the problem.
It would be nice if the module switched to Gitlab CI or fixed Drupal CI for automated testing.
Because the default tests fail via a deprecation error:
Comment #15
dqd@kksandr: Thanks for coming back on this. Much appreciated.
Agreed. Feel free to open an issue for that. I would embrace that! +1 for the reminder.
Minor misunderstanding here: I was referring to minor gramma and typo in code comments as a minor nit pick review.
Thanks for the reroll! +1 For all the hard work in here. Will review the reroll asap.