开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜