function mymodule_search_form($form, &$form_state) {
$form..... define the form here
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Search',
);
return $form;
}
function mymodule_search_form_submit($form, &$form_state) {
//process the form and get result
$output = this is the result with a table of data.
//I want to display the result table here.
//Now I can only use drupal message to display on top.
drupal_set_message($output);
return;
}
Run Code Online (Sandbox Code Playgroud)
所以基本上我想要一个表单从数据库中搜索一些东西.点击提交后进行搜索,即可获得结果.
我想在同一表单页面的表单下显示结果. 不要转到另一页,只需在原始表单页面中.
表格可以清理/重置为原始状态,这很好.
http://drupal.org/node/542646 这个讨论是我想要的,但那里看起来没有可靠的结果/解决方案.
尝试在新的内容类型添加表单中添加一些额外的表单项。
还要尝试增加提交和预览的权重。
function mymodule_form_alter(&$form, &$form_state, $form_id){
//add some $form items here
$form['actions']['submit']['#weight'] = 2000;
$form['actions']['preview']['#weight'] = 2001;
}
Run Code Online (Sandbox Code Playgroud)
但不知何故,提交和预览按钮仍然位于添加的新项目上方。