Closed (duplicate)
Project:
Drupal core
Version:
7.x-dev
Component:
documentation
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Jun 2011 at 16:11 UTC
Updated:
23 Jun 2011 at 20:56 UTC
Looking at #326564: hook_validate documentation suggests form_set_value(), but not possible it seems that the statement
if it is really necessary to change the node at the validate stage, you can use form_set_value().
is wrong for hook_node_validate too.
Comments
Comment #1
jhodgdonThe argument about hook_validate() was partly, at least, because hook_validate() doesn't have $form_state as an argument, and therefore you can't use form_set_value().
But hook_node_validate() does have $form_state as an argument, so it should be possible to use form_set_value() from hook_node_validate(). I think?
Or do you see some reason that form_set_value() can't be used (or have you tried it and had it not work)?
Comment #2
hansfn commentedThree reasons:
1) I wasn't able to use form_set_value, but that might as well be lacking skills.
2) The function signature for hook_node_validate and hook_validate are identical - at least if you look at the docs.
3) Both hook_node_validate and hook_validate are invoked from node_validate.
In other words, AFAICT they should have the same documentation except that hook_node_validate is invoked "after the type-specific hook_validate() is invoked".
PS! I'm reporting this because it seems inconsistent - not because I have closely reviewed the code for the two hooks.
Comment #3
jhodgdonWait. Are we talking about Drupal 7 or Drupal 6?
In Drupal 7, hook_validate() and hook_node_validate() both have $form_state, so the argument used on #326564: hook_validate documentation suggests form_set_value(), but not possible isn't valid. That probably only should have applied to Drupal 6, where the fix was never applied.
I think I should reopen that issue. And probably we should close this one as a duplicate.
Comment #4
hansfn commentedI was talking Drupal 7 all the time.
I'm just looking for consistency so closing this and reopening the other issue is fine. Thx.