Submit Function for form in Drupal

0
Your rating: None

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.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.

Cumulus Tag Cloud

Kiran Says

I love work environment which is:

Informal yet professional
Demanding yet rewarding
Challenging yet inspiring
Mediocrity is not an option
Having fun is serious business
Making mistakes is human
Forgiveness is Company Policy

Travelling Sucks