开发者

Drupal: drupal_get_form specify file to search

How to specify file to search for 开发者_运维问答a function drupal_get_form?


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".


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';
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜