Redirecting the User

The return value of the function that processes the form is a Drupal path to which the user will be redirected, such as node/1234. If there are multiple functions in the #submit property, only the return value of the last function called will be used. If the function does not return a Drupal path, the user is returned to the same page (that is, the value of $_GET[ 'q']). Returning FALSE from the final submit function avoids redirection.

The return value of the function can be overridden by defining a #redirect property in the form, such as $form['#redirect'] = 'node/1' or $form['#redirect'] = array('node/1', $query_string, $named_anchor). The actual redirection is carried out by drupal_goto(), which returns a Location header to the web server.

Was this article helpful?

0 0

Post a comment