Posted by hansfn on June 22, 2011 at 4:11pm
2 followers
Jump to:
| Project: | Drupal core |
| Version: | 7.x-dev |
| Component: | documentation |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (duplicate) |
Issue Summary
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
#1
The 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)?
#2
Three 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.
#3
Wait. 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.
#4
I was talking Drupal 7 all the time.
I'm just looking for consistency so closing this and reopening the other issue is fine. Thx.