[development] Unsetting form values on validate
Derek Wright
drupal at dwwright.net
Tue Oct 21 06:21:43 UTC 2008
On Oct 20, 2008, at 8:05 PM, Michael Prasuhn wrote:
> I see that in my hook_nodeapi under the validate op, I am getting
> the node, and the $form itself, not $form_state or $form_values.
That's because of this critical bug in the D6 API:
http://drupal.org/node/241364
"hook_validate() doesn't get $form_state passed to it"
Sadly, since that'd be a pretty major API change in a supposedly
stable release series of core, it's probably not going to be fixed. :
( But, it makes hook_nodeapi() quite useless in many cases, and has
caused (and will continue to cause) all sorts of grief for a variety
of modules. Tragically, no one noticed until after 6.0 was out. The
current work-around is to form_alter() and add your own #validate
handler, which *does* get a copy of $form_state as nature intended.
Arguably, that's cleaner than using hook_nodeapi() in the first
place, but then what's the point of having hook_nodeapi('validate')
at all?
This is yet another good anecdote to encourage contrib maintainers to
make heavy use of the UNSTABLE-N tags that webchick is making from D7
core, so that we flesh out broken parts of the API before it's too
late to fix them.
Meanwhile, it'd be nice if Gabor and/or Dries would weigh in on
#241364 and indicate if it's a D7 only issue, or if we should attempt
to make a solution for D6, too. So far, none of the core maintainers
(or major contributors, for that matter) have participated in that
issue.
Cheers,
-Derek (dww)
More information about the development
mailing list