• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Form validation callback not executed when rules are located in config/form_validation.php

#1
[eluser]luismartin[/eluser]
I defined all the validation rules in
config/form_validation.php

and this is the rule:

Code:
$config = array(
     // other validation groups.....,
     'articles' => array(
          // other validated fields.....,
          array(
                'field' => 'date_p',
                'label' => 'Publishing date',
                'rules' => 'callback_match_date'
          )
     )
);

Note that I couldn't use a rule like this:

Code:
regex_match[/^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[012])\/(19|20)\d\d$/]

because it generated an error in the preg_match function, and as I've been told, pipes are buggy in CodeIgniter validation rules. So I decided to use the specified callback "match_date", which is implemented this way:

Code:
function mach_date($date) {
        /* DEBUG */ echo 'Here I am!'; exit;
        return (bool)preg_match('/^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[012])\/(19|20)\d\d$/', $date);
    }

I've placed it within the controller in which the form validation is run. But the echo is not being reached.

Any help?

#2
[eluser]luismartin[/eluser]
It was just a misspelling. I missed the "t" in "mach_date".

The callback actually works within the controller class.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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