cakephp, select for a form are generated with a query -


i have query in controller

$clientslist = $this->client->query("select client_name clients active=1"); 

how can show clients list select in form?

echo $this->form->input('clientname', array('type' => 'select', 'options' => ??????)); 

thanks


edit

i've solved problem

in controller

$clientslist = $this->client->find('list', array('fields' => array('client.client_name'), 'conditions' => array('client.active' => '1')));         $this->set('clientslist', $clientslist); 

in view

echo $this->form->input('cliente', array('type' => 'select', 'options' => $clientslist)); 

i have problem now

in view value of every option of selectbox id how can use name of client in value?

change query following:

$clientslist = $this->client->find('list', array('conditions' => array('client.active' => '1'))); 

this automatically build option list of id, name use in select box.


Comments