Detect in form_alter if the node submitted is added or edited

2009
15
Dec

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 ? Smiling

Similar Posts
Related Searches




Comments

Post new comment

The content of this field is kept private and will not be shown publicly.