Welcome Guest, Not a member yet? Register   Sign In
Loading helpers/librarys in _construct
#1

[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:

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!!


Messages In This Thread
Loading helpers/librarys in _construct - by El Forum - 08-24-2009, 10:45 AM
Loading helpers/librarys in _construct - by El Forum - 08-24-2009, 10:49 AM
Loading helpers/librarys in _construct - by El Forum - 08-24-2009, 12:01 PM
Loading helpers/librarys in _construct - by El Forum - 08-24-2009, 12:12 PM
Loading helpers/librarys in _construct - by El Forum - 08-24-2009, 12:35 PM
Loading helpers/librarys in _construct - by El Forum - 08-24-2009, 12:49 PM
Loading helpers/librarys in _construct - by El Forum - 08-24-2009, 01:27 PM
Loading helpers/librarys in _construct - by El Forum - 08-24-2009, 01:54 PM
Loading helpers/librarys in _construct - by El Forum - 08-24-2009, 02:10 PM
Loading helpers/librarys in _construct - by El Forum - 08-24-2009, 02:23 PM



Theme © iAndrew 2016 - Forum software by © MyBB