I want to add a multi select drop down to my gc add form.i could generate a single select drop down using set relation.but i dont know how to make it multi select drop down.please help,thank you!
$crud->set_relation('color','tbl_color','color');
with this i could get a single selection drop down list.
Grocery CRUD multi select drop down list
3k Views Asked by HPM At
2
There are 2 best solutions below
0
On
add the following to your code after $crud->set_relation,
$this->db->select('*');
$querydata = $this->db->get('tbl_color')->result(); // to get whole table values
$resultarray = array(); // defines a new array
foreach ($querydata as $result) {
$resultarray[$result->color] = $result->color; //initializing table values to the array
}
$crud->field_type('color', 'multiselect', $resultarray); // setting multiple select
Hope this will help, because its working fine for me.
checkout the documentation for relation_n_n.
http://www.grocerycrud.com/documentation/options_functions/set_relation_n_n