Needs work
Project:
Drupal core
Version:
main
Component:
forms system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
8 Mar 2010 at 22:53 UTC
Updated:
21 Jul 2025 at 04:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
c960657 commentedReroll.
Comment #2
retester2010 commented#1: redirect-3.patch queued for re-testing.
Comment #4
kenorb commentedI've similar problem for 6.x: #987066: Simple way to create button which do redirect
Comment #5
Anonymous (not verified) commentedmarked #329706: Allow buttons to use #redirect as a duplicate
Comment #6
sunGood suggestion.
This essentially moves the 'redirect' declaration into the form constructor, which has been asked for many times in a range of other issues already.
We should:
1) Ensure that a button-level #redirect is applied to $form_state['redirect'] before submit handlers are invoked, so submit handlers are able to override it.
2) Still allow to declare a form-level $form_state['redirect'] - which is used when no button-level #redirect is defined.
On 2) specifically, there's #1251616: $form_state['redirect'] does not work in form constructors, which will ultimately bring consistency with regard to this issue; i.e., if you can specify #redirect on a button, then you should also be able to specify $form_state['redirect'] in the form constructor.
Comment #7
sunThere's a problem with the approach taken in #1:
A mere declaration of #redirect should not break the entire form submission. Essentially, we only want to take over the value of #redirect into $form_state['redirect'].
We still need to invoke button-level #submit handlers, if any are defined.
However, if no button-level #submit handlers are needed, then the form-level #submit handlers will be invoked, which is obviously wrong. We need to decide what to do in that case:
A) If a button defines #redirect, but no #submit, then automatically inject an empty array for #submit; i.e., no submit handlers are invoked, and form processing directly hops to
drupal_redirect_form(); e.g.:B) If a button defines #redirect and does not need submit handlers, but does not want form-level submit handlers to get invoked, then it has to manually specify an empty #submit array, too.
Comment #8
sunAttached patch implements #7.A)
I did not include any of the conversions from #1, since I think we need to agree on the API behavior first.
Comment #24
smustgrave commentedThank you for creating this issue to improve Drupal.
We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.
Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!
Comment #25
smustgrave commentedFeel may still be a valid task