继续Drupal分享精神 QQ群:107748121 站长QQ:2275288328 skype: hellodrupal【drupal交流+drupal 建站+theme制作】
登录 注册

使用hook_menu 传递参数到form 表单里

这样也可以传递参数到form里,动态显示form title表单的名称

<?php
function sitemod_menu(){

 
$items = array();


  
$items['mytest/drupal_form'] = array(//定义menu
   
'title' => t('Test Form'), // Page title 定义
   
'page callback' => 'd_form',// Call back function 调用form 函数
   
'access arguments' => array('access content'),// 访问权限
    
'page arguments' => array('Hi,guys,I am an arg :('),// 传递到form表单title里面
   
'type' => MENU_CALLBACK,
  );
    return
$items;
}


function
d_form($arg) {
  return
drupal_get_form('get_d_form',$arg);
}

function
get_d_form($form_state,$arg) {
    

 
$form['name'] = array(
   
'#type' => 'textfield',
   
'#title' => t($arg),//得到传过来的参数
 
);

  return
$form;
}
?>

效果如下图

评论

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 自动断行和分段。
  • You can use BBCode tags in the text.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.