> But there is one thing I did want to mention re. http://web2py.com/books/ > > default/chapter/29/07/forms-and-validators#Sharing-forms > <http://web2py.com/books/default/chapter/29/07/forms-and-validators#Sharing-forms>. > > Indeed I did read > that section but it was the comment: > "What we discuss here is possible but not recommended, since it is always > good practice to have forms that self-submit." > > that prompted me to start the thread, I was interested in why it was "not > recommended". >
In the Overview chapter in the section on Postbacks, there is this: *The mechanism for form submission that we used before is very common, but it is not good programming practice. All input should be validated and, in the above example, the burden of validation would fall on the second action. Thus the action that performs the validation is different from the action that generated the form. This tends to cause redundancy in the code.* There are other ways to avoid code redundancy (as in the shared form example), but the self-submission pattern is a handy one. As already mentioned, other benefits are that (a) you don't have to specify (and worry about possible future changes to) a submit URL, (b) upon failed validation, you don't have to store errors in the session and then do a redirect, and (c) after successful submission, you don't need a redirect if you simply want to reload a new empty form. Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.