(04-08-2015, 09:31 AM)sv3tli0 Wrote: Form validation inside a model is not acceptable for me. You don't send requests to models to validate them, this is a joke I hope.
The current rules are nice I don't say that they should be replaced.
What I mean is to move all things outside the controller into a separate Form type class which will handle the form request and it will apply all filters/validation rules (which will contains all callback methods..).
This will clean your controllers and you will have just to call this form element(class) and to run the validation command(method) nothing more..
I just create a library for that. Each method in the library just contains the rules for the form fields needed and returns the result of $this->form_validation->run()
Then in the controllers, I just do:
PHP Code:
if ($this->form_library->validate_add_user())
{
//it validated
}
else
{
//validation error
}