Closed (fixed)
Project:
Drupal core
Version:
6.15
Component:
forms system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
29 Apr 2008 at 17:26 UTC
Updated:
22 Oct 2012 at 06:50 UTC
In 5.x one could add a "$form['#redirect']" to a node form to send Drupal to the page I wanted. In 6.x this still works for add or edit, but it causes delete to not delete the node, with no indication why it didn't. I can fix the delete redirect problem by setting $_REQUEST['destination'] in hook_delete. Unfortunately, that leaves add and edit in limbo. I guess I'm going to have to try a submit handler, which really should not be necessary.
Comments
Comment #1
nancydruComment #2
damien tournoud commentedWell the node delete option skipped the FormAPI logic completely in Drupal 5. This was fixed in Drupal 6, and now you are bound to the logic behind
drupal_redirect_form(), that seems to say:$form_state['redirect'] = false, do not redirectI think that logic is seriously flawed.
$form_state['redirect']should have precedence over$form['#redirect']. This seems more consistent with the wording of the FormAPI documentation (emphasis mine):Moving to the development queue because that issue is also present there.
Comment #3
nancydruIt seems silly to have to create a submit function to get the redirect to (hopefully) work.
Comment #5
gregstout commentedI had to do this redirect in hook_nodeapi (using $_REQUEST['destination'] = '<>') to get it to work for insert, update, and delete in Drupal 6.x
Comment #6
nancydruI did it in hook_delete and hook_update. I guess the lack of core attention here means that this bug will persist in 7.x since we are now in "code slush."
Comment #7
effulgentsia commentedSubscribing to look at later. If an API change is needed, probably too late for D7, but if it can be fixed without an API change, it's still on the table.
Comment #8
jefftrnr commentedI think I'm having trouble with a similar issue. What if a destination was checked for first before setting the new redirect path to the form array?
Doing this seems to have fixed it for me. We were having trouble with the delete button in the user/edit form.
Comment #9
sunThis should already be fixed due to #579366: How many ways are there to redirect after form submission?
Please confirm that the bug actually still exists.
Comment #10
effulgentsia commentedConfirming that this is fixed for D7. $form_state['redirect'] is the sole place for setting the redirect (well, $_GET['destination'] takes precedence, but modules should not be setting that directly, though they can construct URLs that include a destination parameter). Default submit handlers set $form_state['redirect'], so anything that wants to change it needs to implement an additional submit handler that runs after the default one. This is potentially an argument for a new form processing stage (post_submit?), but that should be taken up in a separate issue. If someone opens that, please link to it from here.
Comment #12
chrislynch42 commentedThis problem still exists for 6.16.
Comment #13
Jonah Ellison commentedHere's a workaround to prevent premature redirecting if the delete button is clicked, without using an additional submit hook:
Comment #14
tmsimont commentedJonah's soultion didn't do it for me... I wanted to change the destination parameter based on a condition in the _form_alter... I won't get into why but i had to. Jonah's code skips scenarios where the destination is already given.
To redfine the post-deletion destination (simulating a change in the action variable) with hook_form_alter() -- even if the destination was already passed -- on the "node_delete_confirm" form in drupal 6:
my variables are verbose.. your code could better demonstrate brevity
Comment #15
ranga143 commentedThis is very usefull for me..it's working fine....thanks for this post...