I have a controller for a contact page similar to the following:
@expose('project.templates.contacts')
def contact(self, **kw):
return dict( form=contact_form )
Upon submission the form is validated using the following controller method:
@validate(form=contact_form, error_handler=contact)
@expose()
def processContact(self, **kw):
# Do some processing on the contact form
redirect('contact')
The is the setup advocated by many online tutorials (such as http://turbogears.org/2.0/docs/main/FormBasics.html).
My issue is the URL that is exposed when the contact form is submitted with bad data and @validate calls the error_handler method.
I.e.
- "http://domain/contact" - the user goes to the contact page and fills in the form and click submit
- "http://domain/contact" - if there are no errors in the form, the user is successfully redirected to the contact page.
- "http://domain/processContact" - if there are errors in the form, the contact function is called but there is no redirection from the exposed processContact 'page' so the url remains the same.
I'm looking for a way (the correct way?) to prevent the user from having to see "http://domain/processContact". Ideally the user should only ever see "http://domain/contact".