Getting Multi-select data from a form |
[eluser]Bionicjoe[/eluser]
My app has a multi-select field in one form, but when submitted to the db only one item is inserted. Any help is appreciated or point me to a good tutorial that shows creating a multiselect in CI from a db table and then adding the selections to the record table. View to make the multi-select Code: <tr><td>Location </td><td><?php echo form_multiselect('sitename', $siteoptions); ?></td></tr> Model to get the multiselect options from the db Code: function sitemultiselect() Controllers to add Code: function addoutage()
[eluser]chazy (aldever calvo)[/eluser]
hi.. may i ask how you solved the problem?.. i am having similar problem... but mine doesnt add anything at all.
[eluser]defectivereject[/eluser]
This was my solution. (Obviously going into your model to write the record back to your database!!!) Code: $data = array(); EDIT!! Oh and your form multiselect MUST be an array as follows Code: echo form_multiselect('input_name[]', $name, '', 'id="input_name"');
[eluser]chazy (aldever calvo)[/eluser]
this was what i did... in this post: http://ellislab.com/forums/viewthread/180856/ i'll try using implode and explode... it'll be my first time to use those functions...
[eluser]chazy (aldever calvo)[/eluser]
thanks... i have the values now, but still not inserted... Code: A Database Error Occurred i followed your code and this is my model: Code: function AddSetMaterial($actNum, $actMat) for my controller: Code: function setmaterials() Code: <?php $actMat= $this->input->post('actMat[]');?>
[eluser]chazy (aldever calvo)[/eluser]
it's good if i changed the datatype of my db form integer to varchar... i hope theres another way of storing multiple int values because my goal is to insert the integer values per row of the column...
[eluser]defectivereject[/eluser]
try changing this line Code: 'ch_act_mat_mat_id' => implode(", ", $values), to this Code: 'ch_act_mat_mat_id' => implode(",", $values), The only thing i can think of as an INT field would accept any spaces as they aren't numbers
[eluser]chazy (aldever calvo)[/eluser]
done that... the problem doesn't change... the values could not be stored per row...
[eluser]chazy (aldever calvo)[/eluser]
solved in this thread http://ellislab.com/forums/viewthread/180856/ |
Welcome Guest, Not a member yet? Register Sign In |