Welcome Guest, Not a member yet? Register   Sign In
an array in name field in a form?
#1

[eluser]ajsie[/eluser]
in the documentation it says that you can have an array in the name field.

Code:
<input type="text" name="options[]" value="<?php echo set_value('options[]'); ?>" size="50" />

but i dont get why u would do that. could someone explain?
#2

[eluser]InsiteFX[/eluser]
Did you read this?

Form Validation

Look towards the bottom Using Arrays as Field Names.

InsiteFX
#3

[eluser]Clifford James[/eluser]
I use an array in my forms to group data (for different database tables), like an user and settings:

Code:
<input type="text" name="user[name]" />
<input type="text" name="user[email]" />

<input type="text" name="user_settings[language]" />
<input type="text" name="user_settings[group]" />

I can now access only the user data very easily trough:
Code:
$this->input->post('user'); // array('name', => 'value', 'email' => 'value')

And the settings
Code:
$this->input->post('user_settings'); // array('language' => 'value', 'group' => 'value')
#4

[eluser]ajsie[/eluser]
thanks clifford james! that helped me to understand!




Theme © iAndrew 2016 - Forum software by © MyBB