Welcome Guest, Not a member yet? Register   Sign In
weird problem with form helper
#1

[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" />
#2

[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
#3

[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.
#4

[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
#5

[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




Theme © iAndrew 2016 - Forum software by © MyBB