I have created custom form and on submit of that form, I need to fetch data from database and need to display that content in well structured format in different template.
I am able to create form, on submission, I am able to fetch data from database but I am not able to pass that result to another template and display data on that template. I have also tried with
function nexposed_menu() {
$items = array();
$items['form-example'] = array(
'title' => 'Example Form',
'description' => 'A form to mess around with.',
'page callback' => 'drupal_get_form',
'page arguments' => array('nexposed_form'),
'access callback' => TRUE
);
return $items;
}
function nexposed_form($form, &$form_state) {
$toppings = array(
'Jan' => t('Jan'),
'Feb' => t('Feb'),
'Mar' => t('Mar')
);
$form['month'] = array(
'#title' => t('Months'),
'#type' => 'checkboxes',
'#description' => t('Select the Month'),
'#options' => $toppings,
);
$form['submit_button'] = array(
'#type' => 'submit',
'#value' => t('Click Here!'),
);
return $form;
}
function nexposed_form_validate($form, &$form_state) {
}
function nexposed_form_submit($form, &$form_state) {
drupal_set_message(t('Search submitted successfully.'));
$query = db_select('node', 'node');
$query = $query->fields('node', array('nid', 'title'));
$query->condition('node.type', 'events');
$rows = $query->execute()->fetchAll(PDO::FETCH_ASSOC);
return theme('event_page', array('data' => $result, 'paging' => $paging));
}
Where $result
contains data in the key value pair format, but that template is not called rather no result is displayed.
Any help regarding this is highly appreciated. Thanks in advance.