Detect in form_alter if the node submitted is added or edited

When you want to alter a form on Drupal, it is useful to detect if the form being submitted is to add a new node or edit an existing node. To detect if a form is being added or submitted, check the

$form[<content-type>]['nid']['#value'] .

Example : $form['book']['nid']['#value'] .

If the value is "new", the node is being added.
If the value is numeric, the node with nid as the number is being edited.

Anyone got better ideas ? :)

15 Dec, 2009
Related Searches
perl hash remove node
Comments (0)
You may also like
On Facebook
Email Newsletter