Also applies to D7.

The problem:

From hook_validate documentation:

Changes made to the $node object within a hook_validate() function will have no effect. The preferred method to change a node's content is to use or hook_nodeapi($op='submit') instead. If it is really necessary to change the node at the validate stage, you can use function form_set_value().

I want to call form_set_value from within hook_validate as per documentation. However, hook_validate receives two arguments $node and $form while form_set_value requires three arguments $node, $form, AND $form_state to do the job. In other words calling form_set_value from within hook_validate is impossible since you do not have the form_state in that hook.

I have a specific requirement that I need to set the title of a node if and only if some other values validate.

Comments

mdupont’s picture

Version: 6.9 » 7.x-dev

Setting it to D7 since D6 is in maintenance mode.

Status: Active » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.