• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.