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

[eluser]darkhouse[/eluser]
I tried a brand new version of CI, and that still didn't help. I ended up changing my code to this, which I know is a little silly, but it works and allows me to move on, though I still want this callback issue figured out... so weird.

I have my own message system, so I just used that inside the callback (or what used to be a callback) and now I run it after the validation runs, along with a success variable that I set to FALSE if something happens. If it's still TRUE by the time it gets to the end, then I display the success message.

Code:
function search(){
    $rules = array(
        array('field'=>'check_in', 'label'=>'Check In', 'rules'=>'trim|required|xss_clean')
    );
    $this->form_validation->set_rules($rules);
    if($this->form_validation->run()){
        $success = TRUE;
        
        if(!$this->_valid_check_in($this->input->post('check_in'))) $success = FALSE;
            
        if($success){
            $this->message->set('Success', 'success');
        }
    } else {
        $this->message->set(validation_errors(), 'error');
    }
    $this->load->view('book_room');
}
    
function _valid_check_in($date){
    if($date < date('Y-m-d')){
        $this->message->set('Check in date must be today or later.', 'error');
        return FALSE;
    }
    if($date > date('Y-m-d', time()+60*60*24*365.25)){
        $this->message->set('Check in date too far in advance.', 'error');
        return FALSE;
    }
    return TRUE;
}

But if anyone else has any insight into my initial callback issue, I'd really appreciate it. 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