Welcome Guest, Not a member yet? Register   Sign In
Form Validation (with form in site footer)
#1

[eluser]Mantishead[/eluser]
I have planted a form into my site footer (which I regret).

It is a mailing list signup and it appears on every page of the site (in the footer). There are many, many pages to the site.

I want to validate the form data but because the form is present in every page, it would seem I need to put the form validation if/else construct into every method in my controller class.

When the submit button passes the form post data to the method specified in the form action, if the data is invalid is there no way of having it call the 'calling' page with the error post data - rather than having to specify the views it should load?
#2

[eluser]Damien K.[/eluser]
With many, many pages, you may want to look into some template "engine" to address issues like this and others.

I assume you don't like the work flow:
if on input error, show the "main" mailing list sign up page with error messages

This does redirect users to a different page. However, many sites do adopt this work flow. One way to achieve the redirect to the calling page is to use the referrer url. Storing the calling url in a dynamically set hidden field is an alternative. Ideally, you would use JavaScript for client-side validation and add AJAX for server-side validation.

I personally don't mind the work flow with users being redirected to main sign up page on error.




Theme © iAndrew 2016 - Forum software by © MyBB