CodeIgniter Forums
Form Help - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Form Help (/showthread.php?tid=43753)



Form Help - El Forum - 07-21-2011

[eluser]BenSeagrave[/eluser]
Just watched the tutorial on the codeigniter site about making the blog. When making the form for the comments, he doesn't use functions like form_input() or form_textarea(). Is this for a reason or were the functions recently added. Also, how would I go about making a text area with form_input field. I tried to use the user guide but I didn't really understand as it doesn't declare anywhere that it's a text area.

example from user guide:

Code:
$data = array(
              'name'        => 'username',
              'id'          => 'username',
              'value'       => 'johndoe',
              'maxlength'   => '100',
              'size'        => '50',
              'style'       => 'width:50%',
            );

echo form_input($data);

// Would produce:

<input type="text" name="username" id="username" value="johndoe" maxlength="100" size="50" style="width:50%" />


I don't understand why this would come out as a text input field?
Thanks


Form Help - El Forum - 07-22-2011

[eluser]LuckyFella73[/eluser]
The userguide tells us this - should work:
Code:
$data = array(
              'name'        => 'username',
              'id'          => 'username',
              'value'       => 'johndoe',
              'rows'   => '8', // "rows" instead of "Maxlength" as with input type text
              'cols'        => '50', //"cols" instead of "size" as with input type text
              'style'       => 'width:50%'
            );
echo form_textarea($data);



Form Help - El Forum - 07-22-2011

[eluser]Rok Biderman[/eluser]
If you're confused as for why should a thing like this actually exist - this is a helper, something to help you with making forms. It's basically a function that produces valid forms in a way that makes it easier to define it from a controller. You can easily choose not to use it, but it grows on you, not to mention it automates csrf_protection token, so you don't have to worry about it.


Form Help - El Forum - 07-22-2011

[eluser]boltsabre[/eluser]
I think that the csrf_protection only works if you use form_open(), just using:

echo form_textarea($data); (or whatever input field/s you need for your form)

won't automatically implement csrf protection.


Form Help - El Forum - 07-22-2011

[eluser]Rok Biderman[/eluser]
By using form helper I meant everything, but of course, it's the form_open that actually does it.