• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Codeigniter custom validation rules in model

#5
@dbui

I use the same approach, a callback wrapper within the controller with a tiny difference (tried on CI3):

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

In my code it would be:

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

And:

Code:
public function validate_user($str) {

would be:

Code:
public function _validate_user($str) {

Ugly a little bit, but this prefixed with "_" callback rule can not be called by the router.
Reply


Messages In This Thread
RE: Codeigniter custom validation rules in model - by ivantcholakov - 01-09-2015, 12:45 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.