Working out callback ordering is trickyThere are now lots of levels of callbacks to work with:
- Old node hooks (hook_load, hook_form, etc)
- nodeapi hooks - based on $op, they all happen after the corresponding node hook
- hook_form_alter - replaces old hook_nodeapi:form call
- Validate and Submit callbacks set up in form with FormAPI - So there are now potentially 3 different places to do validation
- inputs: &$node, but ignore it - nothing useful in it yet, and any changes are rejected. Pull data from db.
- outputs: object(hash) that will get merged with node.
- goal: move data from db into node
- ? why not just allow you to modifiy $node?
- inputs: &$node with info from _load. Pull data from $_POST and $_SESSION
- outputs: changes to $node persist down chain.
- goal: make changes to $node based on non-submit actions
- inputs: &$node - now fully loaded with $_POST['edit'] array (and data from _load and _prepare)
- outputs: returns the bad-ass form array. Can modify $node, but that would be odd(?)
- goal: build the form array
- inputs: $node: filled with all form_values(RO), $form: form array
changes to $node are lost, and changes to $form are pointless. Use
form_set_value( $form['id'], new_value ) to modify the values in $node
before submission (weird). Use form_set_error( 'id', 'message' ) to
abort the submission.
- goal: change to reject the form submission.
- ? why make it so hard to modify $node, but still possible ?
- inputs: &$node with all the trimmings
- outputs: modificatons to $node persist
- goal: last chance for tweaking before heading to the db(?) Mostly for _form_alter chaining
- inputs: $node (RO)
- outputs: updated db tables
persist extra node info to the db. Called after node_u/i. If this is
an insert, this is the first moment you have a nid (important if you
are doing bonus db changes that need to link back to this node).