⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

.:: fulfillment of a Drop Down list



elanouar

elanouar
  • profile picture
  • Member

Posted 18 July 2013 - 02:48 AM

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.


davidoster

davidoster
  • profile picture
  • Member

Posted 18 July 2013 - 05:06 AM

Check here: /topic/1578-filter-relation-using-third-table/#entry6865


elanouar

elanouar
  • profile picture
  • Member

Posted 18 July 2013 - 09:01 AM

Nice DavidOster,

Thank you indeed.

Yours.


davidoster

davidoster
  • profile picture
  • Member

Posted 19 July 2013 - 07:12 AM

You welcome!