Drupal coder: hook_form: is this node new ?

Submitted by Frederic Marand on Tue, 2005-09-13 00:23

hook_form is used both for adding new nodes and editing existing ones, and no parameter is passed to describe the current operation.

Why is it not needed ? Because a simple test can show whether the node is being added or edited:

isset($node) && isset($node->nid)

If the test succeeds, the node has already been created and someone is editing it. Otherwise, it is being created. This can be important for node modules generating values beyond $node->nid for the nodes they handle.

Tagged for , .

Anonymous (not verified)

Sat, 2006-08-19 02:42

Good to know... this should really be added to the drupal documentation somewhere.