如何在钩子形式alter中定义的提交处理程序中获取节点ID

时间:2011-10-11 12:25:09

标签: php drupal variables drupal-7

我可以使用不同的钩子来获取提交的新节点的node_id吗?

function dc_project_management_form_bug_request_node_form_alter(&$form, &$form_state, $form_id)
{
    $form['#submit'][] = 'dc_project_management_process_bug_request_milestone_submit';
}

function dc_project_management_process_bug_request_milestone_submit($form, &$form_state)
{
    //NULL when submitting new node
    $form_state['values']['nid'];
}

1 个答案:

答案 0 :(得分:5)

此时节点尚未实际保存,您需要实现hook_node_insert

function dc_project_management_node_insert($node) {
  $nid = $node->nid;
}