Jump to content


.:: fulfillment of a Drop Down list


  • Please log in to reply
3 replies to this topic

#1 elanouar

elanouar

    Member

  • Members
  • PipPip
  • 27 posts

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.



#2 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 18 July 2013 - 05:06 AM

Check here: http://www.grocerycr...able/#entry6865


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#3 elanouar

elanouar

    Member

  • Members
  • PipPip
  • 27 posts

Posted 18 July 2013 - 09:01 AM

Nice DavidOster,

Thank you indeed.

Yours.



#4 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 19 July 2013 - 07:12 AM

You welcome!


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users