【问题标题】:How to fix warning that function 'node_form' is not found?如何修复未找到函数“node_form”的警告?
【发布时间】:2011-01-22 20:36:20
【问题描述】:

我正在编写一个drupal 模块。 在我的模块中,我有以下内容:

在我的.module 文件中,我有:

function mymodule_managment_menu(){
$items = array();
$items['management/edit'] = array(
    'title' => 'Add Node',
    'page callback' => 'display_add',
    'access callback' => 'user_access',
    'file' => 'file.inc',
  );
  return $items;
}

在我的 file.inc 中有:

function uc_am_display_edit()
{
  global $user;
  $node = array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => 'track', 'language' => '');
  $output = drupal_get_form('track_node_form', $node);
  return $output;
}

当我转到http://myhost/management/edit 时,我收到以下警告消息:

警告:call_user_func_array() 期望参数 1 是有效的 回调,函数“node_form”不是 在中找到或无效的函数名称 /var/www/includes/form.inc 在线 378.

调试时,我得到 form.inc:378,即:

  $form = call_user_func_array(isset($callback) ? $callback : $form_id, $args);

我的 $callback = 'node_form'。 但仍然没有定义。 当然,当我转到http://myhost/node/add/track 时,我得到了我想要的正确设计的表格。 当我调试它时,我会抛出相同的代码路径,具有相同的变量值,并声明 node_form。 所以我在这里的猜测是我的模块是在节点模块之前加载的,但只是写这会让人怀疑,因为节点模块是一个核心模块。 试图将我的模块重量值增加到 11 - 没有帮助。 请帮忙...

【问题讨论】:

    标签: drupal drupal-6 drupal-modules


    【解决方案1】:

    函数node_form 定义在modules/node/node.pages.inc 中。默认情况下不加载该文件。您必须在页面回调中使用 module_load_include 手动加载它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-23
      • 2012-05-09
      • 2019-08-08
      • 2020-11-28
      • 2017-10-25
      • 2017-07-03
      • 1970-01-01
      • 2019-12-07
      相关资源
      最近更新 更多