Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm using computed field to generate a field used in the auto node title. I have to edit the node twice to get the correct title to show up.
1. Is there any way to get the computed field to "compute" a couple of times so the data is there?
2. Is there a way to get the computed field to "compute" before the auto node title?
Comments
Comment #1
asb CreditAttribution: asb commentedHow do you get the computed field's value into the node title? In my setup, computed field does not expose it's values as token, so there's no replacement pattern I could enter for automatic title generation.
Thanks & greetings,
-asb
Comment #2
clarkburbidge CreditAttribution: clarkburbidge commentedAll my cck fields are available as tokens. I don't know what I did to get it that way. I thought that was standard.
Comment #3
Moonshine CreditAttribution: Moonshine commentedWhile this response may be too late for you, I think your problem may be related to this:
#414088: Computed fields should compute on $op='presave' and/or $op='validate'
while I'll be looking into here...
Comment #4
clarkburbidge CreditAttribution: clarkburbidge commentedThis is still and issue for me. I'm not sure if 'presave" would fix the issue. Currently I have a views bulk operation that I run occasionally to band aid the issue. I'd love to see it fixed, but I think it is more the way I have it set up with a nested computed CCK fields as one of the tokens for my auto node title. Thanks for info and I'll be following the results!
Comment #5
csc4 CreditAttribution: csc4 commentedI'm sure you're right - the computation has to happen before the value is tokenised or the value can't be available.
I'd been thinking it was simply an issue with module weights?
I've been struggling with the same problem. Is it as simple as patching the module to change the operation to presave or are there other considerations?
Comment #6
TripleEmcoder CreditAttribution: TripleEmcoder commentedSubscribing.
Comment #7
KerriO CreditAttribution: KerriO commentedSubscribing
Comment #8
millenniumtreeAghghh! Yes!
Comment #9
brycesenz CreditAttribution: brycesenz commentedSubscribing.
Comment #10
Anonymous (not verified) CreditAttribution: Anonymous commentedSubscribe
Comment #11
Moonshine CreditAttribution: Moonshine commentedThis should be fixed per #414088: Computed fields should compute on $op='presave' and/or $op='validate'
Comment #13
texas-bronius CreditAttribution: texas-bronius commentedFor anyone stumbling across this.. I found a win in passing a value in the $node (auto_nodetitle) and $entity (computed_field) objects like:
Auto Node Title config on content type using PHP eval:
(include php tags)
Computed Field config:
(omit php tags)
Bonus tucked in, so here's what all is going on:
The added bonus here is that my computed field does *not* update with each node save (desired behavior in my use case). The overall take-away here is that auto_nodetitle has access to and can modify $node and fires before computed_field which has access to and can modify $entity. Note: You can always debug with dsm($node) and dsm($entity) in the respective eval blocks with the devel module.
Appears to work for me thus far... hth