Don't use drupal_goto to redirect forms in submit handler

robertDouglass - February 8, 2009 - 22:19
Project:Webmail Plus
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Issue tags:ApacheSolr
Description

<?php
function webmail_plus_solr_searchbox_submit($form, &$form_state) {

 
$keyword = $form_state['values']['webmail_plus_solr_seach_keyword'];

 
_webmail_plus_solr_add_history($keyword);
 
drupal_goto('webmail_plus/solr_search/'.$keyword);
}
?>

To determine where the user should be sent after the form is processed, the _submit function can place a path or URL in $form_state['redirect'] which will be the target of a drupal_goto; every form is redirected after a submit. If you store nothing in $form_state['redirect'], the form will simply be redirected to itself after a submit. It is polite to use drupal_set_message() to explain to the user that the submission was successful.

http://api.drupal.org/api/file/developer/topics/forms_api.html

#1

robertDouglass - February 8, 2009 - 22:37
 
 

Drupal is a registered trademark of Dries Buytaert.