CodeIgniter Forums
weird problem with form helper - 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: weird problem with form helper (/thread-10134.html)



weird problem with form helper - El Forum - 07-20-2008

[eluser]Bramme[/eluser]
Hi all,

I've got a weird problem with the form helper. I'm setting an array in my controller, which I use to build my form.

Code:
$data['form'] = array(
    'hidden' => array(
        'name' => 'tutID',
        'value' => $tutID
    ),
    'name' => array(
        'name' => 'name',
        'id' => 'name',
        'value' => $this->validation->name
    ),
    'password' => array(
        'name' => 'password',
        'id' => 'password'
    ),
    'email' => array(
        'name' => 'email',
        'id' => 'email',
        'value' => $this->validation->email
    ),
    'message' => array(
        'name' => 'message',
        'id' => 'message',
        'value' => $this->validation->message
    ),
    'submit' => array(
        'name' => 'submComment',
        'value' => 'Submit'
    )
);
And then in my view I use this:
Code:
<?=form_open($this->uri->uri_string().'#comments'),"\n"?>
    <?=form_hidden($form['hidden']), "\n"?>
    <p><label for="name">NAME&nbsp;&nbsp;<span class="small green">( required )</span><br />
    &lt;?=form_input($form['name'])?&gt;</p>
    <p><label for="password">PASSWORD&nbsp;&nbsp;<span class="small green">( if you are a forum member )</span><br />
    &lt;?=form_password($form['password'])?&gt;</p>
    <p><label for="email">EMAIL&nbsp;&nbsp;<span class="small green">( required, but won't be published )</span><br />
    &lt;?=form_input($form['email'])?&gt;</p>
    <p><label for="message">MESSAGE&nbsp;&nbsp;<span class="small green">( required )</span><br />
    &lt;?=form_textarea($form['message'])?&gt;</p>
    <p>&lt;?=form_submit($form['submit'])?&gt;</p>
&lt;/form&gt;

However, the weird thing is, in my source code, I suddenly see this:
Code:
&lt;input type="hidden" name="name" value="tutID" /&gt;&lt;input type="hidden" name="value" value="192" />



weird problem with form helper - El Forum - 07-20-2008

[eluser]Randy Casburn[/eluser]
&lt;?=form_hidden($form['hidden']), "\n"?&gt;

the form_hidden() function does not take an array as an argument -- check the docs

That's a start..

Randy


weird problem with form helper - El Forum - 07-20-2008

[eluser]Bramme[/eluser]
I always check the docs, I just didn't think of the fact it wouldn't take array's, just like all the other form_ helpers. edit, thanks though. problem solved now.


weird problem with form helper - El Forum - 07-20-2008

[eluser]Randy Casburn[/eluser]
I just meant "verify what I'm saying because this is off the top of my head and sometimes I'm a fool". -- Didn't mean to come off as offensive - :red:

Randy


weird problem with form helper - El Forum - 07-20-2008

[eluser]Bramme[/eluser]
No worries no worries. I'm not offended and didn't want to appear though. I was merely making excuses for myself why I didn't properly check the docs :p

That's the downside of internet communication... Without emoticons, we'd be lost. Smile