Drupal:drupal_get_form指定要搜索的文件

发布于 2024-10-03 13:16:09 字数 34 浏览 0 评论 0原文

如何指定文件来搜索函数drupal_get_form?

How to specify file to search for a function drupal_get_form?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

乖乖公主 2024-10-10 13:16:10

如果您指的是用作页面回调的表单,则可以在 file 参数中指定文件名:

/**
 * Implementation of hook_menu().
 */
function MODULENAME_menu(){
    return array(
        'my/form' => array(
            'page callback' => 'drupal_get_form',
            'page arguments' => array('MODULENAME_myform'),
            'file' => 'myform.inc',
            //
            // ...
            //
        ),
    );
}

在该示例中,函数“MODULENAME_myform”返回以下表单结构: drupal_get_form 用于构建页面“www.yoursite.com/my/form”,并存储在文件“myform.inc”中。

If you mean a form used as page callback, the file parameter is where you can specify a filename:

/**
 * Implementation of hook_menu().
 */
function MODULENAME_menu(){
    return array(
        'my/form' => array(
            'page callback' => 'drupal_get_form',
            'page arguments' => array('MODULENAME_myform'),
            'file' => 'myform.inc',
            //
            // ...
            //
        ),
    );
}

In that example, the function "MODULENAME_myform" that returns the form structure that drupal_get_form uses to build the page "www.yoursite.com/my/form" is stored in the file "myform.inc".

顾冷 2024-10-10 13:16:10

使用 include_oncerequire_once需要添加表单所在的文件。 drupal_get_form 自动注意包含表单。

例如 :

include_once drupal_get_path('module', 'modname') .'/file.php';

use include_once , require_once or require for adding files where the form resides . drupal_get_form automatically takes care to include the form.

for example :

include_once drupal_get_path('module', 'modname') .'/file.php';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文