15 Dec, 2009

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 ? :)


Related Searches
perl hash remove node
Comments (0) Post a comment
You may also like



Email Newsletter
Email:
Popular Posts
Recent Posts
Tags
Random photo
One of the vertex of havelock island One of the vertex of havelock island in Havelock Island Andaman
On Facebook
Recent Comments


digitalpbk