Kārlis Janisels Kārlis Janisels - 4 years ago 115
PHP Question

How to extend CodeIgniters library?

So I have fallowed every rule there is on CI docs page but still get error

Call to undefined method CI_Form_validation::clear_field_data()


I placed file MY_Form_validation.php in application/core directory :


class MY_Form_validation extends CI_Form_validation {

public function __construct()
{
parent::__construct();
}

public function clear_field_data() {

$this->_field_data = array();
return $this;
}
}


and then in my controler I load class as usual:

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


and use my new method:

$this->form_validation->clear_field_data();
$this->load->view('product/create', $data);


Have spent hours on this, I am sure that I am missing something silly but realy can not find it on my own. Would appreciate if someone could point to mistakes in my attempt to extend library.

Answer Source

Your own libraries must be in the folder: application/libraries

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

$this->form_validation->clear_field_data();
$this->load->view('product/create', $data);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download