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;
}
So basically I want to have a form to search something from database. Once click the submit to search, and get the result.
I want to display the result just under the form in the same form page. Do not go to another page, just in the original form page.
The form can be clean/reset into original status, which is fine.
http://drupal.org/node/542646 This discussion is what I want, but there looks no solid result/solution there.
You can stash the output table in the $form_state
, set the form to rebuild, and display it if it exists in the original form function, e.g.
function mymodule_search_form($form, &$form_state) {
$form..... define the form here
if (!empty($form_state['results_table'])) {
$form['results_table'] = array('#markup' => $form_state['results_table']);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Search',
);
return $form;
}
function mymodule_search_form_submit($form, &$form_state) {
$form_state['results_table'] = function_to_get_table();
$form_state['rebuild'] = TRUE;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With