08-24-2009, 10:45 AM
[eluser]Braden Schaeffer[/eluser]
I'm not sure I understand how the _construct function works in CI.
What seems like a straight forward way to load helpers and librarys is giving me fits. I've searched the forums and googled the hell out of this, but I am still not clear on what to do. I also understand that I can auto load helpers and librarys, but I'm not sure that's really what I want. Stacking your auto_load has got to be the wrong way to go.
Here's some quick example code:
And I'm getting this non-object error when I call the form_validation helper afterwords:
I'm sure loading helpers in the _construct function is possible. It has to be. Or... maybe it's not possible.
Someone has to know how to do this.
Thanks in advance!!
I'm not sure I understand how the _construct function works in CI.
What seems like a straight forward way to load helpers and librarys is giving me fits. I've searched the forums and googled the hell out of this, but I am still not clear on what to do. I also understand that I can auto load helpers and librarys, but I'm not sure that's really what I want. Stacking your auto_load has got to be the wrong way to go.
Here's some quick example code:
Code:
class Edit extends Controller {
function __construct()
{
parent::Controller();
$this->load->helper('form');
$this->load->library('form_validation');
}
function myForm()
{
$this->form_validation->set_rules('input', 'input', 'required');
//More code here...
}
}
And I'm getting this non-object error when I call the form_validation helper afterwords:
Quote:Fatal error: Call to a member function on a non-object in /nfs/c05/h01/mnt/70148/domains/themesaur.us/html/application/controllers/edit.php on line 12
I'm sure loading helpers in the _construct function is possible. It has to be. Or... maybe it's not possible.
Someone has to know how to do this.
Thanks in advance!!