Closed (works as designed)
Project:
Drupal core
Version:
6.2
Component:
forms system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
30 May 2008 at 14:13 UTC
Updated:
18 Nov 2009 at 23:24 UTC
node_form_submit() runs after any other submit handlers that you may have created in hook_form() hook_form_alter(). And it sets the $form_values['redirect'] whether or not it exists already in the form. This means that a module cannot redirect the node/add/type form to another location.
This patch adds an isset($form_state['redirect']) conditional around the redirect declaration in node_form_submit(). This will keep any previously declared redirect from being destroyed.
| Comment | File | Size | Author |
|---|---|---|---|
| node.pages_.inc-redirect.patch | 720 bytes | jjeff |
Comments
Comment #1
quicksketchAfter talking with Jjeff, we determined that the problem was that the node submission handling is no longer handled by a general #submit function on the $form variable, but instead a #submit attached to the Submit button. Placing a #submit function on the button after the node module's submit function works fine to return a different redirect path.
Comment #2
momper commentedis this fixed in the current 6.6 release?
greetings momper
Comment #3
sp3boy commentedAs it took me rather a long time to understand and succeed with the suggestion in comment #1, here is some code which worked for me (eventually) in my module btomccmessage:
I had to figure out the
$form['buttons']['submit']['#submit'][]reference before Drupal would take any notice of the redirect.I'm using D6.6 so the answer to the second comment (which you probably already know) is no.
Comment #4
dutchslab commentedthanks for the example sp3boy, it worked for me like a charm as well.
geremy
Comment #5
heacu commentedsubscribing -- still not fixed in drupal core!
Comment #6
momper commentedhow to put it into core?
Comment #7
lizhenry commentedLooks like this would also be useful patch to help the nodegoto module come up to Drupal 6.
Comment #8
sreynen commentedYou can also force your submit handler to run after node_form_submit by adding a #validate function, and appending your submit handler to the $form_state['submit_handlers'] array. Still feels a bit messy, but the button #submit solution broke something else for me.
I'm still not clear on why node_form_submit needs to override $form_state['redirect'].