Welcome Guest, Not a member yet? Register   Sign In
Codeigniter custom validation rules in model
#2

In CI 2.x I don't believe it was possible to use a callback method from the model. It always looked in the Controller.

However - the solution is to have a function in a helper that you can load prior to running the validation. Then, you treat it as a normal PHP function and not a callback, changing that line to:

Code:
$this->form_validation->set_rules('email',       "email",'validate_user');

Another solution, to keep the code in the same place, and break a few rules about organizing code in the process Smile is to simply include that function in the same file as the model. It's not ideal, obviously, but it does work (just don't tell anyone I recommended that. ha!)
Reply


Messages In This Thread
RE: Codeigniter custom validation rules in model - by kilishan - 01-09-2015, 09:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB