CodeIgniter Forums
Multiple helpers not loading properly (specifically form and url) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Multiple helpers not loading properly (specifically form and url) (/thread-6756.html)



Multiple helpers not loading properly (specifically form and url) - El Forum - 03-10-2008

[eluser]Jay Turley[/eluser]
I don't know if this is due to my CI noobness, but just in case, I'm going to post it here.

In my controller, I have the following:

Code:
function index() {
        $this->load->helper('form','url');
        $this->load->view('user_form');
    }

When I create the view, the following code breaks. By this I mean that the rendered html source terminates with the submit tag. There is nothing following it, no anchor, no html closing tag, no nuthin'!

Code:
$attributes = array('name' => 'new_user_form', 'id' => 'new_user_form');
    echo form_open('user/create', $attributes);
    echo form_label('Username', 'username');
    $inputData = array(
        'name'        => 'username',
        'id'        => 'username',
        'maxlength'    => '20',
        'size'        => '20',
    );
    echo form_input($inputData).'<br />';
    echo form_label('Password', 'password');
    $inputData = array(
        'name'        => 'password',
        'id'        => 'password',
        'maxlength'    => '20',
        'size'        => '20',
    );
    echo form_password($inputData).'<br />';
    echo form_submit('addnewuser', 'Create Account');
    // THIS IS WHERE THE CODE BREAKS!
    echo anchor('', 'Cancel');
    echo form_close();

After experimenting, it appears the only thing that fixes this issue is to load the helpers separately. With no change to the code at all, suddenly everything works.

Code:
function index() {
        $this->load->helper('form');
        $this->load->helper('url');
        $this->load->view('user_form');
    }

I searched the forum, but found no reference to this.

Thanks!


Multiple helpers not loading properly (specifically form and url) - El Forum - 03-10-2008

[eluser]ontguy[/eluser]
It should be:
Code:
$this->load->helper( array('form', 'url') );



Multiple helpers not loading properly (specifically form and url) - El Forum - 03-10-2008

[eluser]Jay Turley[/eluser]
Oh, and don't I feel stupid for forgetting that </shame>


Multiple helpers not loading properly (specifically form and url) - El Forum - 03-11-2008

[eluser]Derek Allard[/eluser]
Hey Jay, not a problem. I did that just a few weeks ago... and I work with that code for like... 13 hours a day Wink