Closed (works as designed)
Project:
Automatic Nodetitles
Version:
5.x-1.1
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 May 2008 at 15:29 UTC
Updated:
9 Jun 2008 at 08:26 UTC
Module setting title in hook_nodeapi(op=validate) so if we wanna use NID as pattern we cant...
Solution is add hook_nodeapi(op=insert) same as validate but direct update node tables
if ($op == 'insert') {
if ((auto_nodetitle_get_setting($node->type) == AUTO_NODETITLE_ENABLED) || ((auto_nodetitle_get_setting($node->type) == AUTO_NODETITLE_OPTIONAL) && empty($node->title))) {
/*
* Sets the node title.
* We need to do this on validation because of two points:
* It's early engouh to have node previews working and
* it's late enough as CCK has already gone through the 'process form values' step
*
* As changes to $node are not persistent during validation, we use form_set_value()!
*/
auto_nodetitle_set_title($node);
db_query("UPDATE {node} SET title = '%s' WHERE vid = %d", $node->title, $node->vid);
db_query("UPDATE {node_revisions} SET title = '%s' WHERE vid = %d", $node->title, $node->vid);
}
}
Comments
Comment #1
fagoit's no solution, as it won't work for the preview.
Comment #2
andypostIt's solution for insert but for preview suppose to assume that nid is 0 and use
Comment #3
fagoBut it'll set another value as it was previewed - this will just confuse users. So I won't add something like that.
If users *really* need to set the title with fields like the nid, I'd suggest using worklfow-ng. E.g. look at this: http://drupal.org/node/198398