Closed (fixed)
Project:
Automatic Nodetitles
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
31 Jan 2007 at 13:56 UTC
Updated:
27 Feb 2007 at 14:46 UTC
Jump to comment: Most recent file
Comments
Comment #1
fagohm, could you please test again with the latest module?
I've just committed some enhancements.
Comment #2
ray007 commentedI just tested with the lasted dev snapshot, and my title still ends up "1. January 2007" ...
Comment #3
karens commentedI found the problem. Auto_nodetitles is creating a title for the node without calling _content_widget_invoke('process form values', $node) first. That creates a node that has the unprocessed date input values (which are not valid dates themselves) which then fails when it tries to turn those values into formatted dates. 'Process form values' is the step that converts string text and arrays of month/day/year into valid dates, so it is critical.
If you can find a way to run _content_widget_invoke('process form values', $node) on the node values before creating the title it should work right. I dug around in the code but couldn't find the right place to catch this and correct it.
The other question is whether this should be done here or in the token module. I'm not familiar enough with either to be sure where this should take place.
Comment #4
fagothanks KarenS.
CCK does this call on hook_nodeapi type submit, so we could fix this by let the auto_nodetitle module come after CCK (adapt module ordering). Imho that's the appropriate fix. I'll have a look at it as soon as time permits.
Comment #5
ray007 commentedThe signature of auto_nodetitle_validate() did confuse me a bit a first, since it's quite different from what api.drupal.org says about hook_validate(), but the following patch (also attached) seems to do good work ...
Btw: is there a reason the parameters $form_values and $form are not declared as references?
Comment #6
fagoHave you read my last post?
If you'd like to help, please do it that way.
@hook_validate: yes the function name is somehow misleading, it's no implementation of hook_validate. I've renamed it to auto_nodetitle_form_validate().
Comment #7
ray007 commentedJust increasing the weight of the auto_nodetitle module didn't change anything.
We probably need to implement a hook_nodeapi() and put the title-update there?
Comment #8
fagoI've done so, are you using the latest module?
Comment #9
ray007 commentedYes, downloaded the dev-version this morning, so it doesn't have the renamed function in it, but that shouldn't matter.
I've adjusted the weight in the system table (just set it to 5), but that doesn't change anything.
I didn't check whether the call passed actually the if-check in the hook ... and there there someone after us writing everything to DB?
Comment #10
ray007 commentedIf we use the 'validate' op in hook_nodeapi, it all works.
Not sure why why still need to do the call in auto_nodetitle_form_validate() too, but it didn't work when I removed the call to auto_nodetitle_set_title() there.
Patch to the module is attached, but stupid cvs doesn't let me create a patch for a file not yet existing in the repository, so here a
auto_nodetitle.installfile adjusting the weight:Comment #11
fagook, I had a closer look at this.
Setting the weight to 5 fixed it for 'submit', so the title has been set correctly, however there was still an error caused by the validation. auto_nodetitle did its validation through a formAPI submit handler, which was called before CCK so the form values were not processed => error.
I've changed this now to hook_nodeapi like you did, however then setting $node->title is not enough as the changes to $node on validation will not be persistent. (that's why you still needed the formapi validation)
So i did
Which sets the nodetitle in $form_values and so in the resulting $node.
KarenS, while debugging this stuff I saw that CCK is processing the form values three times. I think this should be done only once: on nodeapi $op validate like now, but with setting the changes through form_set_value(), so that they are persistent. That would save two times executing "prepare form values": on nodeapi $op submit and inside content_view().
Comment #12
fagoah I forgot, I tested this with the date field and it does work now as good as the token module does support the cck dates..
-> committed in 5.x and HEAD.
Comment #13
fagofor reference: I've opened a CCK issue for invoking "process form values" only once:
http://drupal.org/node/118645
Comment #14
ray007 commentedHope they don't break us when they fix it ;-)
Comment #15
(not verified) commented