What I am trying to do is use the Form Helper to build a selection pull down menu with options . These options are built from my database. There is over 100 entries in this table. Below is the line of code I use for the find command.
$company = $this->Company->find('list');
This is what I am doing to built it now, but all this does is display one result not all 100.
foreach ($company as $c=>$value) { $test = $value; }
$tmp = $this->Form->input('Client', array('options' => array($test)));
However, if I do this,
foreach ($company as $c=>$value) { $test = $value;
$tmp = $this->Form->input('Client', array('options' => array($test)));
}
This then prints/echos all the results. But each of them is in its own pull down menu, so I have over 100 pull down menus all over my screen. I assume this is because the foreach loop, loops around again and again printing each record until its done them all.
So how can I get this to display only one pull down with all my results/records in it?
I have look at a number of different posts on here and there are a lot of ways to do this but I can’t seem to get any of them to work!
I have opened the form OK, and have already built a pull down list but with an array listed inside that PHP file, so that was easy and works!
Please help?
Thanks Glenn.
Change:
to
Since you are getting list from database which would be in format: