By carlogen on
Hi all,
I will appreciate an help with the following.
I am building a form with a submit form handler.
The form is working well (it give me back the text string i submit)
The problem is that I get the result in a blank page without the theme,
I attach below the code of my submit function.
I do not understand what is wrong.
Thanks
function myform_nameform_submit($form, &$form_state) {
$ricerca = array (
'text' => $form_state['values']['text'],
);
$output = print $ricerca['text'];
return $output ;
}
Comments
The problem by unicode bom
The same of bug
http://drupal.org/node/58918
A few things: Concerning
A few things:
Concerning $output = print $ricerca['text'];
You can drop the word print here as that is printing straight out to the screen instead of stroring the value in $output. The print function always returns 1 so $output would become 1 (see http://php.net/manual/en/function.print.php)
The fact that you are printing directly to the screen is most likely the reason you have lost the rest of your theme, as drupal builds up a themed page of output for each request but I think you are interupting that process here.
Also I dont think it is meaningful to return a value from a form submit function, generally speaking you would do some data storage / processing here and then redirect somewhere else by storing a path in $form_state['redirect'].
If you want to see your value displayed on the redirected page you can drupal_set_message($form_state['values']['text']);