I have a question related to drupal 7 form api and module development.
I have a very simple module with a function like this. It gets called by hook_menu when a certain path xyz is visited.
function myview_mainpage() {
$content .= drupal_render(drupal_get_form('myview_form'));
$content .= "Some additional stuff here";
return $content;
}
My form looks like this (it's from the examples module):
function myview_form($form, &$form_state) {
$form['description'] = array(
'#type' => 'item',
'#title' => t('A simple form with a submit button'),
);
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
);
return $form;
}
And my submit handler looks like this:
function myview_form_submit($form, &$form_state){
// I do some sql stuff and generate html content based on the value that was submitted in the form
$variable = "<div><h1>Some stuff</h1>...';
}
And now I need to somehow pass the value of $variable to the function myview_mainpage() so it can print it out. So in a nutshell: User submits a from, some processing is done based on the value submitted and then the results are displayed under the form when it is displayed.
Maybe I could use $form_state['redirect'] to redirect the user to the page xyz but I don't want to send the value of $variable in the address bar of a browser.
Any ideas? This feels like it should be done quite easily but I can't find a way to do it.