Source: http://api.drupal.org/api/4.7/function/hook_nodeapi

Quote:
"validate": The user has just finished editing the node and is trying to preview or submit it. This hook can be used to check or even modify the node. Errors should be set with form_set_error().

This is not correct. The validate action can only be used to check the submitted form variables. The submit action should be used to modify the node.

Proposed solution: Add the submit action in the list.

"validate": The user has just finished editing the node and is trying to preview or submit it. This hook can be used to check the node. Errors should be set with form_set_error().

"submit": The user is about to submit the node. This hook can be used to modify the node.

Comments

pwolanin’s picture

Here's the current text of "submit", which seems ok to me:

"submit": The node passed validation and will soon be saved. Modules may use this to make changes to the node before it is saved to the database.

Also, I think the "validate" phase could be used to modify the node via form_set_value:

http://api.drupal.org/api/4.7/function/form_set_value

though, obviosuly this is not as simple as modifying it during the "submit" phase

toemaz’s picture

Good description.

I don't know who is in charge to commit this change. What would it take to push this adjustment?

pwolanin’s picture

@toemaz - which description are you in favor of? The one I quoted is already part of the docs. The "validate" op should be changed as you originally suggested.

Anyone with CVS access (including me) can commit changes to the develper docs.

toemaz’s picture

Well, I like your description on the 'submit' action. I would not add the extra information with the form_set_value. Keep it simple.

Tresler’s picture

Assigned: Unassigned » Tresler
Status: Active » Closed (fixed)

Currently reads:

"submit": The node passed validation and will soon be saved. Modules may use this to make changes to the node before it is saved to the database.

"validate": The user has just finished editing the node and is trying to preview or submit it. This hook can be used to check the node data. Errors should be set with form_set_error().

This seems to be what the initial issue was opened to clarify.
Marking closed and assigning self for tracking if re-opened.

Tresler’s picture

Status: Closed (fixed) » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)