Welcome Guest, Not a member yet? Register   Sign In
Error : Callback fucntion is not getting called in New Version of CI 1.7.2
#1

[eluser]Amrish[/eluser]
Code:
function test() {
echo "hi"; exit;
}
function _validate_form() {    
    $this->load->library('Form_validation');
        $config = array(
               array(
                     'field'   => 'client_name',
                     'label'   => 'Client Name',
                     'rules'   => 'callback_test'
                  ),
               array(
                     'field'   => 'client_contact_person',
                     'label'   => 'Client Contact Person',
                     'rules'   => 'required'
                  ),
               array(
                     'field'   => 'client_address1',
                     'label'   => 'Client Address 1',
                     'rules'   => 'required'
                  ),
                 array(
                     'field'   => 'client_margin',
                     'label'   => 'Client Margin',
                     'rules'   => 'required|numeric'
                  )
                  
             );

        $this->form_validation->set_rules($config);    
        if($this->form_validation->run() == FALSE) {
            $this->error = validation_errors('<li>','</li>');
            return false;
        }
        else {
            return true;
        }
    }


I am using code for calling call back function but it is giving me error as

Code:
Fatal error: Call to undefined method CI::test() in C:\xampp\htdocs\vendor-tracking\www\system\libraries\Form_validation.php on line 589
#2

[eluser]danmontgomery[/eluser]
Is this in the model? Callback functions need to be in the controller object
#3

[eluser]Amrish[/eluser]
Both function is present in the controller file.

Also validation function is working like numeric, required but callback is not getting called.

So i check in the Form_Validation Class, comment the continue statement at the line no : 585,

found that CI object is not have the access.

Code:
if ($callback === TRUE)
            {
                if ( ! method_exists($this->CI, $rule))
                {        
                    //continue;
                }
#4

[eluser]danmontgomery[/eluser]
test() isn't recognized as a member of the controller object. Can you post the entire contents of that file?
#5

[eluser]Amrish[/eluser]
See Attached File
#6

[eluser]theshiftexchange[/eluser]
The function test should accept a variable, and return a BOOL (not "EXIT") or it will cause problems.

Code:
function test($str)
{
   return true;
}
#7

[eluser]Amrish[/eluser]
I got solution from this link :

Code:
http://ellislab.com/forums/viewthread/143057/




Theme © iAndrew 2016 - Forum software by © MyBB