Node edit form: edit or new state?
What's the best way of figuring out if a node form is in a Create New Node state or Edit Existing Node 开发者_运维技巧state?
Is there anything in the $form
array or do I have to kludge this with arg()
?
Are you asking for the node edit form? If so, you can either do the following:
if (empty($form['nid']['#value'])) {
// in add form
} else {
// in edit form
}
Or...
if (arg(1) == "add") {
// in add form...
} else {
// in edit form...
}
best way in my option is to check if the form has an NID.
精彩评论