I am building a Form object using pyramid_simpleform. I would like to have one method that builds the form object and once submitted it attempts to validate it.
If the input valid, I’ll redirect the user to a confirmation page. Otherwise, I’ll render an error page. I am using form.validate() to see if the input data fits the schema.
If the form has not been submitted, I’d like to display the form using a render_to_response. How do I detect whether the form has been submitted?
Quick answer
Like Furbeenator answered:
Long answer
You should split your logic in two different view functions.
Also, you should return a form renderer to be used by your template instead of rendering the form straight in the view function. For example:
./forms.py:
./views/accounts.py:
./templates/accounts/register.mako: