form_input() question - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: form_input() question (/showthread.php?tid=45488) |
form_input() question - El Forum - 09-23-2011 [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><?php echo form_submit('Submit', 'Submit') ?></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. |