我正在尝试构建一个必须向sidebar_first添加表单的自定义模块。我尝试使用page_build挂钩,但是没有用。
function module1_page_build(&$page){
drupal_set_message("Inside page builder");
$page['sidebar_first']['filters'] = array(
'#markup' => drupal_form_build('filter_formbuild',$formstate=NULL),
'#prefix' => '<div class="filters">',
'#suffix' => '</div>',
);
}
我创建了一个函数filter_formbuild,它返回一个这样的表单数组。 function filter_formbuild(){
$form = array();
$form['title'] = array(
'#title' => 'Title',
'#type' => 'textfield',
'#size' => '100',
);
$form['url'] = array(
'#title' => 'Name',
'#type' => 'textfield',
'#size' => '100',
);
$form['notes'] = array(
'#title' => 'Notes',
'#type' => 'textarea',
'#maxlength' => 200,
'#size' => '30',
);
$form['author'] = array(
'#title' => 'Author(s)',
'#type' => 'textfield',
'#maxlength' => 30,
'#size' => '100',
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
);
return $form;
}
我认为挂钩未启动,因为set_message也无效。有人可以建议另一种方法来执行此操作,或者我的实现中是否有任何错误。我是drupal自定义模块的新手
答案 0 :(得分:1)
/** * Implements hook_block_info(). */ function custom_block_block_info() { $blocks = array(); $blocks['my_block'] = array( 'info' => t('My Custom Block'), ); return $blocks; }