简体   繁体   中英

how to return error_array(); in codeigniter 2.2.1

trying to return form_validation as an array using _error_array(); by extending the library with the following code in my_form_validation.php

class MY_Form_validation extends CI_Form_validation {

    public function error_array() {
        return $this->_error_array;
    }

}

however i get a call to undefined function n error_array(); in my controller i have $this->form_validation->error_array(); i have tried renaming the my_form_validation.php with MY_Form_validation.php but nothing seems to be working dont know if its done diffrently in codeigniter 2.2.1 compared to other posts on here

'Nothing seems to be working' doesn't help if there is no explanation what is going on on your screen/in yoour application. Regardless, you have to include constructor in your newly created library that calls parent code.

class MY_Form_validation extends CI_Form_validation
{
    public function __construct()
    {
        parent::__construct();
    }

    public function error_array()
    {
        return $this->_error_array;
    }

}

Also, you would load that library without prefix:

$this->load->library('form_validation');

or similarly in autoload.php app config file.

More about Extending Native Libraries .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM