To fulfill a specific need i created a CRUD in which i have a dropdown list.
I have to fulfill the dropdown list with data, and the value of each element would be fixed by my own code.
Thus I created a function in a model in which i have made some joines and return an array . The generated array is composed of 'values' and 'names' of elements that will figure in the dropdown list.
Example of a generated array :
12 , ESS,13,Est,110,CAB....
12 ---->will represent the id of ESS
13 ---->will represent the id of EST
110---->will represent the id of CAB
My model function :
public function groupes() { $datarray =array(); $this->db->select('g.idGroupe,g.nomGroupe'); $this->db->distinct(); $this->db->from('groupe g, usertogroupe u'); $this->db->where('u.idutilisateur', 25); $this->db->join('usertogroupe', 'u.idgroupe=g.idGroupe'); $query = $this->db->get(); foreach ($query->result() as $row) { array_push($datarray ,$row->idGroupe,$row->nomGroupe); } return($datarray); }
Knowing that I use the 'field_type' function and the function that figures in my model I'm unable to create the dropdown list correctly due to third parameter of the field_type function that requires an array as a parameter!!!!
Would you help me to resolve this problem.
Best regards.