The "Automatically generate the label and hide the label field" option does not play nice with Rules.

Created on 15 July 2016, almost 9 years ago
Updated 3 February 2025, 3 months ago

This is related to #1445124: Add support for entity id tokens during creation (but not the same) and please bare with me (long-time Drupal user and tech-savvy so I know what I'm doing and saying)...

Use case: I initially wanted my automatically generated title to contain the node ID, but then realized that my specific use case required sequential numbering, so I ended up using the Serial Field module.

Both node ID and the value provided by the Serial Field module are not available till only after the node has been saved and this causes a series of errors. This is already a known issue and that is where this issue here is related to (but not the same as) #1445124: Add support for entity id tokens during creation . Trying to resolve that problem has lead me to use Rules...

So, my nodes for which I need the title to be auto-generated have a date field and a serial field (hidden from the edit form) and the goal was to have the node title be in the form of [date:Ymd][nid] (initially) or [date:Ymd][serial]. Because of the issue with nid and serial not being available during node creation, I had set AEL to auto-generate the first part of the title in the form of [date:Ymd] and hide the title field from the form. I then used Rules to append the nid or the serial to the auto-generated title. This caused the node to be created, a success status message "[node_type] [date:Ymd][serial] has been created." to be displayed and the page was redirected to my.site.url/[date:Ymd][serial], but the page was actually a 404 "Page not found"...

- Checking the content page (/admin/content) showed that there was a node created, but its title was [node_type] [serial] (notice the space between) and its path was [node_type]-[serial]. The expected result (according to the success status message) would have been [date:Ymd][serial] for both the title and the path (using Pathauto with the pattern set to [node:title]).

If I change the AEL setting to "Automatically generate the label if the label field is left empty", everything works fine: no 404 "Page not found", the node gets its proper title ([date:Ymd][serial]) and the expected URL (my.site.url/[date:Ymd][serial]). But this option leaves the title field exposed in the node edit form. Something that is not desired.

If I disable AEL and try to use only Rules for setting both parts of the title (date+serial), then the title field is still exposed in the edit form and it is required. So, the user has to enter a value (anything) that is useless (it gets replaced by the Rule running after node save). So this adds a pointless step to filling the form.

So, now, I'm pretty much left with using the "Automatically generate the label if the label field is left empty" option as a means to make the title field optional (a waste of AEL potential if you ask me) since the "Automatically generate the label and hide the label field" option causes all these issues.

The way I see it, either #1445124: Add support for entity id tokens during creation gets fixed somehow (doubt it's gonna be anytime soon) and nid/serial are available before node creation (so, AEL works for my use case and I stop using Rules), ...or the issue with the "Automatically generate the label and hide the label field" option is fixed to play nicely with Rules.

Thanx for taking the time to read all this.

🐛 Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

🇦🇺Australia klonos 90% Melbourne, Australia - 10% Larissa, Greece

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024