As per the forms api quick start guide, a _submit function should return the url to be redirected to and not use drupal_goto directly.
http://api.drupal.org/api/file/developer/topics/forms_api.html/5
Look under the section labeled "Submitting Forms", bullet number 4:
The return value of the _submit function will be the target of a drupal_goto; every form is redirected after a submit. If you return nothing, the form will simply be redirected to itself after a submit.
Wrong:
function myform_submit($form, $form_values) {
// do your thing
drupal_goto('somwhere');
}
Good:
function myform_submit($form, $form_values) {
// do your thing
return 'somwhere';
}
There are various forms _submit() function in the mysite module which are calling drupal_goto() instead of returning.
This means that I cannot use hook_form_alter() and override the destination by altering $form['#redirect'] like I am supposed to.
http://api.drupal.org/api/file/developer/topics/forms_api_reference.html...
Comment | File | Size | Author |
---|---|---|---|
#7 | 521246-extended.patch | 6.98 KB | agentrickard |
#1 | 521246.patch | 2.6 KB | roychri |
Comments
Comment #1
roychri CreditAttribution: roychri commentedHere is proposed patch
Comment #2
agentrickardLooks good. Does it break anything?
Comment #3
roychri CreditAttribution: roychri commentedI did not take the time to do full suite of tests.
Does it even have a suite of unit test for d5?
Comment #4
agentrickardGood old fashioned form clicking is the only way to go. The only thing I could see breaking is the fake multi-step form stuff in edit and settings, but I don't see that affected here.
Those gotos(), btw, are a legacy of 4.7.x, I think.
Comment #5
agentrickardLooks good. I will roll a new release.
Comment #6
agentrickardActually, there are instances of these all over the Type includes as well.
Comment #7
agentrickardHere's an extended patch. One good review and I'll roll a new realease.
Comment #8
agentrickard