Welcome Guest, Not a member yet? Register   Sign In
deal with form_input(). Miss parameter.
#1

[eluser]dimaomni[/eluser]
Dear coders.
Don't know what is wrong:

php:
form_input('name['.$students->id.']','','maxlength="2"','size="2"');

result is html:
<input type="text" maxlength="2" value="" name="name[1]">

when I've changed maxlength and size result was like :
<input type="text" size="2" value="" name="name[1]">

I've tried changed parameters placement, but without success.

Thanks!
#2

[eluser]nevsie[/eluser]
I think the problem is that in theory you should only be passing three parameters to this tag in this simple form, in your first line size="2" is effectively the fourth parameter. In this case i would advise using the array approach as in the documentation.

Or this might work:
Code:
form_input('name['.$students->id.']','','maxlength="2" size="2"');

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

echo form_input($data);
note the above could also be done inline rather than creating the array as a separate variable.

Also when posting code make sure it is between code tags. nightmare otherwise.
N
#3

[eluser]dimaomni[/eluser]
[quote author="nevsie" date="1272032451"]
Also when posting code make sure it is between code tags. nightmare otherwise.
N[/quote]

I'll do it. Sorry!

At first I was thinking about array, however I refuse it. But now it seems like the best way.

Thanks!
#4

[eluser]nevsie[/eluser]
why refuse it, it is clean, simple and easier to edit and use the markup... remember you only have to add the bits you want and you can do it inline too:

Code:
echo form_input(array('name' => 'username', 'value' => '', 'maxlength' => '100', 'size' => '50'));




Theme © iAndrew 2016 - Forum software by © MyBB