CodeIgniter Forums
form_input() question - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: form_input() question (/thread-45488.html)

form_input() question - El Forum - 09-23-2011

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:

[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:


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