I use the config.php to store all the form_validation rules…But I would like to store the callback function in one single file too, how can I do so? Any ideas? Thank you….
Now my file is something like this:
User_controller
under user controller have many customized callback_valid , but I ready move all the rules in the config.php. I would like to put the _valid callback to one class. Thank you .
By default, the Form_validation lib uses it’s
$CIproperty to see if the callback method exists. Normally this looks at the current controller. However, you can change this behavior by extending the validation class and altering therun()method.We’re just reassigning the
$CIproperty. So to use callbacks from a class calleduser_validationfor instance, you can do this:Any loaded class will work, so you can store callback rules in models or libraries, just pass the object you want to handle callbacks with to the
run()method.