Welcome Guest, Not a member yet? Register   Sign In
Form validation in different controllers

I want to make different controllers to show form and validate form, but at the same time i want to be able to show a validation message.
So for instance i  want to have a log in form two different places 
1) special page: site/login
2) anywhere on the site in the right top corner of the page 

And i want to share validation logic between them.
So i want two this forms send data on the same controller 
POST - user/validate
And at the same time if password is incorrect (or something else) show a validation error (in different places).

And second part of my question is How can i implement forms with validation on the one page.
Let's imagine a situation.

It's something like a forum - and i have 3 forms on one page -
1) mini login in the right top corner of the page.
2) main form for submitting your post
3) additional post for commenting system

And i wanna validate data from those forms (of course on the different controllers to avoid code duplication) and show validation error on the needed form (so if the password is wrong show it near the form, when you can write a password in, and on the form where you writing a commentary). 
And simultaneously how don't lose entered information? (or is it impossible and you need to implement using JavaScript and store data temporally in cookies?)

I asking this because in the documentation (that honestly is the best one in comparison to all other frameworks) there is the only one example, that shows how to use form validation on the one controller - both rendering and validation (using IF statement to discern if form has been sent or have not), but there is not a word about using it in different controllers or at least different functions of the same controller (and i honestly think for this example it makes absolutely no difference).

And code in controller can quickly become a complete mess if you write everything in one controller, especially if your page contains more than one form.

Theme © iAndrew 2016 - Forum software by © MyBB