Grocery CRUD multi select drop down list

2.9k views Asked by At

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.

2

There are 2 answers

0
Priya Jayapal 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.

0
EstebanArg On