4

What is different between $form_state['redirect'] and drupal_goto() to redirect user to a step in multi step forms in Drupal 6 ? I used $form_state['redirect'] but no redirection happend so I use drupal_goto() .

2

$form_state['redirect'] is not well documented in 6, but my understanding is that when it's populated it will not always work (see the part about exceptions), so although that's documentation for 7, check that other elements of your $form_state are not interfering. If you are working with a multi-step form, it might be that you need to unset $form_state['storage'] first.

drupal_goto() is simply a function will take the user away from the current page to whatever path you specify, and has a bunch of extra features for doing extra things (see the documentation). It is actually called anyway when your form redirects.

When a Drupal form is submitted,$form_state['redirect'] overrides the default form redirect (which will take you to the form you've just submitted) and thus is calling drupal_goto() on your behalf. By putting it in a variable, you can ensure that Drupal handles, in the background, when to do the redirect, rather than you having to specify drupal_goto() directly and getting it wrong.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.