When FAPI was first introduced, developers were told to include a drupal_goto at the end of their *_submit functions. In fact, the proper technique is to return a string with the location you would use in the drupal_goto. This allows other submit functions to run, without being interrupted by a drupal_goto.
As per the updated forms docs:
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. It is polite to use drupal_set_message() to explain to the user that the submission was successful.
This patch removes the drupal_gotos in the LT for the 4.7 branch. It's easy enough to recreate the patch for head, but I don't have the time right now.
I would appreciate this patch being committed because I am writng a module that depends on logintoboggan's validation and submission functions, but I can't be redirected in the middle of the process. (Keep your eyes open for "Register On Submit", a module to allow anonymous users to register and login during a node submission).
Cheers,
-Mark
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | logintoboggan_cvs.patch | 2.36 KB | johnalbin |
| #5 | logintoboggan_470.patch | 2.38 KB | johnalbin |
| #3 | logintoboggan_gotos.patch | 2.37 KB | johnalbin |
| lt_remove_gotos.patch | 1.63 KB | mfredrickson |
Comments
Comment #1
hunmonk commentedthe patch appears to be backwards. :) also, please include the -F^f switch in your diff so that i can see which functions the patch affects.
thanks.
Comment #2
mfredrickson commentedI am all thumbs when it comes to diff. :-)
I'll get that patch rerolled pronto.
Comment #3
johnalbinI looked at the patch and (along with it being backwards) I believe it's not handling properly all the places where
logintoboggan_process_login()is called.Here's an updated patch.
I've verified that this patch allows (for example)
module_form_alter()to set$form['#redirect']for theuser_registerform and to successfully redirect to the proper place. Prior to this patch, loginToboggan always usedvariable_get('toboggan_redirect_on_register', '').Comment #4
hunmonk commentedi'm pretty sure you don't want to use a return in function logintoboggan_user_login_validate
also, it would be nice if this patch also applied to HEAD.
Comment #5
johnalbinYou're right. I guess I got a little over zealous when removing the
drupal_gotocalls.Here's the corrected patch for 4.7.0.
Comment #6
johnalbinAnd here's the patch for HEAD.
Comment #7
hunmonk commentedlatest patches to 4.7 and HEAD look good--applied.
thanks!
Comment #8
(not verified) commented