CodeIgniter Forums

Full Version: Form validation callback not executed when rules are located in config/form_validation.php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

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?

El Forum

It was just a misspelling. I missed the "t" in "mach_date".

The callback actually works within the controller class.