Welcome Guest, Not a member yet? Register   Sign In
form validation callbacks aren't being called
#1

[eluser]darkhouse[/eluser]
Hey guys,

I have a weird issue that, in my 2 years of using CodeIgniter, I've never seen. My form validation callbacks are not being called... at all. Here's my code.

Code:
function search(){
    $rules = array(
        array('field'=>'check_in', 'label'=>'Check In', 'rules'=>'trim|required|xss_clean|callback__valid_check_in')
    );
    $this->form_validation->set_rules($rules);
    if($this->form_validation->run()){
        echo 'success';
    } else {
        echo validation_errors();
    }
}
    
function _valid_check_in($date){
    $this->form_validation->set_message('_valid_check_in', 'Is check in callback even being called?');
    return FALSE;
}

As you can see, I've placed a validation message at the beginning of the callback just to see if it's being called, then I return FALSE. When I run the form, it should just give me that validation error... but it doesn't. I get the 'success' output, signifying the form was validated properly but we know it's not because the callback is set to return FALSE every time... so that means the callback isn't being called.

If I add the valid_email rule to the check_in, the form fails (as it should because this is a date field) and gives me the "Must be a valid email" message. But I still don't get the callback error.

I've tried changing the functions to public instead of private... didn't help. I've tried running it locally as well as on our development server... same issue.

One other thing I did was go into the Form_validation library, into the _execute function and changed this:

Code:
if ( ! method_exists($this->CI, $rule))
                {    
                    continue;
                }

to this:

Code:
if ( ! method_exists($this->CI, $rule))
                {    
                    echo '<pre>', print_r(get_class_methods($this->CI), true), '</pre>';
                    die($rule.' does not exist.');
                    continue;
                }

I get this:

Code:
Array
(
    [0] => __construct
    [1] => CI_Base
    [2] => get_instance
)

_valid_check_in does not exist.

So, it makes sense that my callback wouldn't be called if it doesn't exist... but why doesn't it exist?

I've used callbacks in the past, many times, and never had an issue (aside from my own little bugs). I've been through the documentation multiple times, thinking maybe I overlooked something. Is there something I'm missing? Has anyone ever had this issue before? I've searched the forums, but can't seem to find anybody having the same problem, and that worries me.

Thanks.


Messages In This Thread
form validation callbacks aren't being called - by El Forum - 01-25-2010, 12:50 PM
form validation callbacks aren't being called - by El Forum - 01-25-2010, 01:37 PM
form validation callbacks aren't being called - by El Forum - 01-26-2010, 02:41 AM
form validation callbacks aren't being called - by El Forum - 01-26-2010, 05:51 AM
form validation callbacks aren't being called - by El Forum - 01-26-2010, 06:00 AM
form validation callbacks aren't being called - by El Forum - 01-26-2010, 04:00 PM
form validation callbacks aren't being called - by El Forum - 02-19-2010, 09:05 AM
form validation callbacks aren't being called - by El Forum - 04-20-2010, 05:56 PM
form validation callbacks aren't being called - by El Forum - 04-26-2010, 02:22 PM
form validation callbacks aren't being called - by El Forum - 05-28-2010, 11:06 AM
form validation callbacks aren't being called - by El Forum - 07-04-2010, 01:15 PM
form validation callbacks aren't being called - by El Forum - 07-13-2010, 07:37 AM
form validation callbacks aren't being called - by El Forum - 08-15-2010, 02:18 PM
form validation callbacks aren't being called - by El Forum - 03-26-2011, 04:18 AM
form validation callbacks aren't being called - by El Forum - 04-18-2012, 01:19 PM
form validation callbacks aren't being called - by El Forum - 10-17-2012, 01:53 PM



Theme © iAndrew 2016 - Forum software by © MyBB