Submit function actual deals with form processing after the form has been validated. It only executes if form validation passed completely. The submit function is expected not to use the return keyword if the intent is to return to the same page.
However, if you want the user to continue to a different page when the form has been submitted, return the Drupal path that you want the user to land on next:
function formexample_form_submit($form, $form_values) {
// Do some stuff.
...
// Now send user to node number 3.
return 'node/3';
}
If you have multiple functions handling form submittal only the return value from the last function will be honored (if
Drupal did the redirect after the first function ran, the others wouldn’t get to run, because the user would have already been redirected).
The redirection of the submit function can be over-ridden by defining a #redirect property in the form.This is often done by using the form_alter() hook.
- Kiran's blog
- 470 reads













Post new comment