Snippets

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



Perl script to remove a directory and contents recursively

2009
26
Nov
2

This is the script for sandeep when he asked me how to delete a directory in perl. rmdir function only removes empty directories. So we need to remove the contents of the directory before removing the directory. So if the directory contains more directories / folders we would have to recursively delete all the directories under the directory. Well so here is the code just to do that.

Read More

Syndicate content