【问题标题】:Drupal Hook menu - textfield not showingDrupal Hook 菜单 - 文本字段未显示
【发布时间】:2016-06-13 13:44:13
【问题描述】:

我正在尝试了解模块和挂钩菜单。 我按照本教程进行操作。 https://www.youtube.com/watch?v=bjxML7A19Zs

My Hello Page 链接有效,可将我带到正确的页面 (http://localhost:8012/Adrupal/content/weee)。我的问题是文本字段和标题(输入您的姓名)没有出现。我正在使用 Drupal 7。我没有为本教程下载任何额外的模块。

每次更改后,我都会刷新缓存。

文件地址:all/modules/hello/hello.module

function hello_menu(){
 $items=array();
 $items['content/weee']=array(
    'title'=>'My Hello Page',
    'description'=>'My Hello users',
    'page callback'=>'drupal_get_form',
    'page arguments'=>array('hello_showHelloForm'),
    'access callback'=>'user_access',
    'access arguments'=>array('access content'),
    'type'=>MENU_NORMAL_ITEM
 );
 return $items;

}

function hello_showHelloForm($form, &$form_state, $argument){
 $form=array();
 $form['name']=array(
 '#type'=>'textfield',
 '#title'=>'Enter your name'
 );

 return $form;

}

我不知道我做错了什么。任何帮助都会被挪用。

【问题讨论】:

    标签: drupal-7 drupal-modules


    【解决方案1】:

    你的回调函数没有提供参数

    function hello_showHelloForm($form, &$form_state, $argument) {}
    

    【讨论】:

    • 我已将您的更改添加到我的代码中。不幸的是,它不起作用。
    【解决方案2】:

    如果您在 $form 前加上“&”,就会发生这种情况:

    func_name(&$form, &$form_state)
    

    【讨论】:

      猜你喜欢
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多