Guys,

I created a form and set $form['#redirect'] = ''; but later on _submit(), i changed the $form_state['redirect'] to another value, with no effect. If matter, is was an array with two values: the url and GET values. According to documentation, it should be enough to set the $form_state['redirect'] to make it work.

it seems that drupal_redirect_form() prefers the value from $form['#redirect'] instead from $form_state['redirect'], which goes as the second argument.

regards,

massa

Comments

dropcube’s picture

Priority: Critical » Normal
Status: Active » Closed (works as designed)

A redirection only occurs if the $form_state['storage'] bundle, and the $form_state['rebuild'] flag has not been set.

$form['#redirect'] is used if $form_state['redirect'] is not set.

aurels’s picture

>> A redirection only occurs if the $form_state['storage'] bundle, and the $form_state['rebuild'] flag has not been set.

What do you mean by "if the $form_state['storage'] bundle"?

function awsomemodule_form_submit($form_id, $form_state) {
        // blah
	$form_state['#redirect'] = '<front>';
}

Is this kind of code supposed to work on Drupal 6?

Thanks.

aurels’s picture

It wasn't a problem, I just had forgotten to pass the second argument by reference!

kaine’s picture

hi guys,

I have a different problem, I want to redirect my form to a page by setting the $form['#redirect'],
but where does it have to be settled?