form does not respect #redirect parameter if added using hook_form_alter()
| Project: | Ajax |
| Version: | 6.x-1.14 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | brendoncrawford |
| Status: | active |
Jump to:
I have a situation where i'd like to redirect a node_form to a different URL after it is submitted.
The correct approach to doing this is using the form API and using a hook form alter such as -
function mymodule_form_alter(&$form, $form_state, $form_id) {
if($form_id === 'node_form'){
$form['#redirect'] = array('url');
}
}However if i do this the AJAX module does not respect my #redirect parameter in the $form array since it only looks in $form_state for the redirection.
my suggestion would be to first check the $form['#redirect'] if there is one, redirect there, else fall back on to $form_state['redirect']
does this sound sensible, or should we do this using another approach, for example have my module populate $form_state['redirect'] on a submit func before the ajax submitter is called??
if my suggestion sounds sensible, i'm attaching a patch to cover this.
| Attachment | Size |
|---|---|
| ajax.module.patch | 346 bytes |

#1
Taylzor,
Thanks for this feedback. You have a very good point here. I will add this fix shortly.
#2
Fixed in 6.x-1.x-dev. Please allow up to 12 hours for dev package to update.
#3
Fixed in 6.x-1.x-dev. Please allow up to 12 hours for dev package to update.
#4
Automatically closed -- issue fixed for 2 weeks with no activity.
#5
I looked and this patch is not in the latest dev version. What gives?
#6
By the way, #redirect can accept the following and all need to be checked for:
<?php
$form['#redirect'] = 'node';
?>
<?php
$form['#redirect'] = array('user/login', 'destination=node');
?>
<?php
$form['#redirect'] = FALSE;
?>
http://api.drupal.org/api/file/developer/topics/forms_api_reference.html...
Also, this should override destinations as well.
#7
I am also having an issue with this. It has prevented me from using the ajax module. The redirections from either logintoboggan or logintoboggan are not working. Instead users are directed to the home page.
#8
Oops. I meant the redirections from either logintoboggan or *login_destination* are not working.
#9
subscribing
#10
subscribing
#11
subscribing
#12
subscribing
#13
same here....