Hy,
I am currently converting a simple search module I created for a drupal site to the 4.7 core, but i am experiencing some problems.
My old module had a search page that consisted of two parts:
- The search form
- The results of the search, when a search was done.
The classic way was to implement a callback menu function
function pletdb_menu(){
global $user;
$items = array();
$items[] = array('path' => 'pletdb/search','title' => t('Custom search'),'callback' => 'pletdb_custom_search', 'access' => user_access('search pletdb'), 'type' =>MENU_CALLBACK);
return $items;
}
Then I had the function
function pletdb_custom_search(){
// Code that creates the form elements, ending with the form() function
$output = form($form)
// ... setting the variables for later processing
$op = isset($_POST['op']) ? $_POST['op'] : '';
$edit = isset($_POST['edit']) ? $_POST['edit'] : '';
// ... execute if the form is submitted ...
if ($op == t('Submit')) {
// ... Create a query with the elements that are posted on the form ...
$result = db_query($query);
// ... proces the $result and format into a nice table (html string in $result_table variable)
$output .= $result_table
}
Now, how can I do this with the new form api. Can someone describes a best practice how I can create a form and display the output of my search underneath?