If we want to alter a node form of a specific content type using hook_form_alter(), we may want to know whether the form is for node creation or edit. In this case, we can add a checking as follow:
function <module>_form_<content-type>_node_form_alter(&$form, &$form_state, $form_id) {
$node = $form_state['node'];
if (isset($node ->nid)) {
// Node edit
} else {
// Node add
}
}
Done =)

Thanks for sharing this useful tip.
LikeLike
You are welcome. =)
LikeLike
Reblogged this on Dubai Web Developer.
LikeLike
how to validate and submit form, Please share a format?
LikeLike