CodeIgniter Forums
CI form help - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: CI form help (/showthread.php?tid=31414)



CI form help - El Forum - 06-17-2010

[eluser]UdayD[/eluser]
I just read that to write a form input i have to write as below:
Code:
$data = array(
              'name'        => 'username',
              'id'          => 'username',
              'value'       => 'johndoe',
              'maxlength'   => '100',
              'size'        => '50',
              'style'       => 'width:50%',
            );

echo form_input($data);
but if i have to write 10 inputs with same length, size and style.
how will i do that do i need to make ten different arrays and the pass them to
echo form_input($array1);...
how will i do this?? is their a simpler way?
Thanks in advance


CI form help - El Forum - 06-17-2010

[eluser]UdayD[/eluser]
i got it how can i do that

Code:
$options=array(
              'maxlength'   => '100',
              'size'        => '50',
              'style'       => 'width:50%',
            );
$array1=array{ 'name'        => 'username',
              'id'          => 'username',
              'value'       => 'johndoe',
                }
$array2=array{ 'name'        => 'email',
              'id'          => 'email',
              'value'       => '',
              }
$array3=array{ 'name'        => 'Phone',
              'id'          => 'phone',
              'value'       => '',
              }

and then i can write

echo form_input($array1,$options);
echo form_input($array2,$options);
echo form_input($array3,$options);



CI form help - El Forum - 06-18-2010

[eluser]Ivar89[/eluser]
Make an array and name is tomsething
then in there you sart an array with arraysTongue
Code:
$config = array('contact' => array(array('field' => 'fieldname',
                                            'label' => 'bedrijfsnaam'
                                            'rules' => 'trim|required|callback_check_form'
                                             ),
                                     array('field' => 'fieldname',
                                           'label' => 'Naam',
                                           'rules' => 'trim|required'
                                             ),
                                    array('field' => 'fieldname',
                                          'label' => 'adress',
                                          'rules' => 'trim|required'
                                             ),
//and so on and add Id's and whatever you want.
EDIT: Oh crap I read it wrong I posted a form validation srryTongue


CI form help - El Forum - 06-18-2010

[eluser]Ivar89[/eluser]
simpler way?
Code:
<label id="input">
&lt;input type="text" name="name" Id="id" value="value" style="widht: 500px" /&gt;
</label>



CI form help - El Forum - 06-18-2010

[eluser]UdayD[/eluser]
means use direct form elements.not to use CI form helper???


CI form help - El Forum - 06-18-2010

[eluser]Ivar89[/eluser]
yhea, I mean its easier it doesn't say you HAVE to use the helper...