I'm trying to populate a dropdown/select tag in cakephp,fortunately I was able to populate it with the values coming from my database, however it displays ALL. How can I limit the population to a specific ID?

To make things clear here's what I want to achieve:

Apples:
form start
dropdown-contains only values that are associated with apples from the DB
button
form end

Currently here's how it looks like

Apples:
form start
dropdown-contains all fruits values from the DB
button
form end

Here's my current code tnx any help/suggestions is very much appreciated

Controller:

$fruits = $this->Model1->Model2->find('list', 
array('fields' => 
array('id', 
'fruit_name',
//'conditions' => array(''=>'')
)));
$this->set('fruitsList', $fruits);

View:

echo $this->Form->input('Model1.salad_fruits_id', 
array('type' => 'select', 
'options' => $fruitsList,
));

Related posts

Recent Viewed