Welcome Guest, Not a member yet? Register   Sign In
form_input() question
#1

[eluser]Unknown[/eluser]
Hello,
I have a product, which can contain two or more colors as attributes, and I'm trying to submit these in a form, so here is the code in the form (simplified):

<?php echo form_open('main/form_in');

foreach ($colors as $color) {
echo form_input('colors', $color['value']) . br();
}
?>

<p>&lt;?php echo form_submit('Submit', 'Submit') ?&gt;</p>

So at this point my $colors array looks like this:

Array
(
[0] => Array
(
[name] => product_color
[value] => white
)

[1] => Array
(
[name] => product_color
[value] => black
)

)

In my controller the code is:

function form_in() {

$colors = $this->input->post('colors');
}

But when I submit the changes, for example if I change the colors to green and red, only the last color value is returned.
Here is what my $colors variable looks like in my controller:

red

Can someone tell me, how to submit both color values in one form?
Thank you.




Theme © iAndrew 2016 - Forum software by © MyBB