I have a need to do a redirect after a user clicks on a submit button, where I set cookies and redirect back to calling page, the call goes to mytheme_submit($form, &$form_state) where I have tried everything I know about in Drupal API:
1. Tried $form_state['redirect'] = 'node';
2. Tried unset($form_state['storage']);
3. Tried mytheme_my_form_alter(&$form, &$form_state, $form_id) ~ $form['access']['submit_save']['#submit'][] = 'my_submit_function'; > $form_state['redirect'] = $base_root;
I'm trying to set cookies; which also doesn't seem to take; not sure if the header is already set; seems it shouldn't be; could be the redirect;
I took the same code and put it in a module and it works fine; but has some very bad side effects; which I might have to fix and keep this approach if I can't find a way to do it in the Theme itself.
This seems so easy; I'll try the PHP way and see if that works; but I was hoping to do it the Drupal way.
Thanks in advance for any help.
Comments
_
I use drupal_goto - see http://api.drupal.org/api/function/drupal_goto/6
Pete.
This doesn't seem to work in
This doesn't seem to work in a theme either; I have a feeling it has something to do with the header state; header('Location: http://mydomain.com'); didn't work either.
Normally this will work; but not here
header("Status: 301"); # 301 Moved Permanently
header("Location: http://{$_SERVER['SERVER_NAME']}/node");
exit;
I'm at a real lose for why this is.
_
Where 'in the theme' are you doing this?
I used drupal_goto in a module... what side-effects were you getting?
Pete.
In template.php function
In template.php
function mytheme_submit($form, &$form_state)
{
$form_state['redirect'] = 'node';
}
> I took the same code and put it in a module and it works fine; but has some very bad side effects;
I can not read in Theme setting in Module http://drupal.org/node/547642
Thanks