[eluser]theprodigy[/eluser]
If I load a library or helper in the constructor of MY_Controller, is that library or helper usable by the controllers that extend MY_Controller?
MY_Controller:
Code:
function MY_Controller()
{
parent::Controller();
$this->load->model('MAdmin');
$this->load->library('form_validation');
if(!$this->session->userdata('logged_in'))
{
redirect('admin/login');
}
$this->data = array();
}
extended class:
Code:
function add()
{
$data['errors'] = '';
$this->form_validation->set_rules('name', 'Name', 'trim|required');
if ($this->form_validation->run() == FALSE)
{
if(array_key_exists("name",$_POST))
{
$this->data['errors'] = "<p style='color:red;font-weight:bold;'>Gallery Name is required<p>";
}
$this->data['main'] = "galleries/add_gal";
}
else
{
//get form info
$this->data['gallery'] = $this->input->post('name');
$this->data['notes'] = $this->input->post('description');
//add gallery to database
$this->MGalleryAdmin->add_gallery($this->data['gallery'],$this->data['notes']);
//set main variable with what gets displayed
$this->data['main'] = "galleries/gal_added";
}
$this->show_page();
}
I'm asking because this function "add" is throwing an error on
Code:
$this->form_validation->set_rules('name', 'Name', 'trim|required');
is there a way for me to make the resource available to children controllers?
Thanks