Hi,
I am writing a module to extend a already existing node type. I followed the pattern of using a form_alter to add some elements. Now I want to add some validation logic also. So the handbook suggested that it should be done in nodeapi under the op 'validate'. The problem is that nodeapi in my module is never called with op = validate !
I did some investigation and this is what happens. in the node_form of original type, '#validate' is being explicitly set to node_form_validate. If I remove that, everything is fine and my nodeapi is called with 'validate' op.
My question is if it is the expected behavior or a bug since nodeapi is supposed to be called whenever a node is being validated at submission. And if it is the expected behavior then the correct way of including validation logic would be to assign one more '#validation' function using form_alter and put the validation logic there and not in nodeapi as documentation suggests.
Comments
Subscribing
To my newbie ears, this sounds like a bug in the documentation -- the obvious way to proceed is to use hook_form_alter to change the #validate function, as you suggest, rather than fussing around with hook_nodeapi. Apparently the original module author thought so, too. Can you tell us which doc page confused you?
This is the page:
This is the page: http://api.drupal.org/api/file/developer/examples/nodeapi_example.module/5
Having a dedicated validation function also sounds more efficient since nodeapi gets called so many other times also.