computed_field_field should compute on $op='presave'
matt2000 - March 26, 2009 - 00:59
| Project: | Computed Field |
| Version: | 6.x-1.0-beta2 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
This implementation of hook_field currently calculates on $op = 'insert' or 'update'.
Computing on 'presave' instead allows for token replacements to occur.
I had to make this change when using auto_nodetitle module with multiple computed_fields in the title string.

#11
Interesting... while I think this change should be fine, I'd like to run a couple questions by yched first. So this one is pending a couple answers.
#14
I got here because I have the same problem with Computed Field tokens and auto_nodetitle.
Thanks for the fix matt, even if it is not approved yet :)
Cheers !
#24
I understand the fix but I cannot get it to work for me. After I change the code all I get is a blank page after hitting save.
I changed the following:
FROM
case 'insert':case 'update':
_computed_field_compute_value($node, $field, $node_field);
break;
TO
case 'presave':_computed_field_compute_value($node, $field, $node_field);
break;
Did I miss something? I am using computed_field 6.x-1.0-beta2 with token 6.x-1.12
Thanks
#25
Just wanted to give some feedback about this approach: we applied the "patch" and everything works as expected. I have this on a live website.
@what4software, that is because you did it wrong :)
From
case 'insert':case 'update':
_computed_field_compute_value($node, $field, $node_field);
break;
It should be:
case 'insert':case 'update':
case 'presave':
_computed_field_compute_value($node, $field, $node_field);
break;
#26
And here is the trivial patch against the latest beta3.
#27
Updating the status so maybe we can get some maintainer feedback.
#28
patch is good for me too.
#29
Patch works for me, too (had the same problem with auto_nodetitle, token and one single computed field in the title)
#30
Subscribing
#31
Subscribing.
#32
patch was successful for me as well - thanks for the great work!
i'm glad i came across this thread
#33
May be this patch will solve the problems like described in this topic: http://drupal.org/node/350404
#34
I don't have access from my current location to my original code to check how I did it before, but I'm wondering if having both case 'insert' and case 'presave' is redundant?