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

I defined all the validation rules in

and this is the rule:

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

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


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:

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?

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.