Hello guys. I want a drop down list, the data in it will come from table. Now solved this problem with following approach.
$contacts = array('' => 'Select Contact');
foreach (Contact::model()->findAll() as $row)
{
$contacts += array($row->id => $row->name);
}
echo $form->dropDownList($model, 'contact_id', $contacts, array('style' => 'width:210px'));
But this is not appropriate approach. But i also tried below which produce errors
echo $form->dropDownList($model, 'contact_id', Contact::model()->findAll(), array('style' => 'width:210px'));
what is the exact approach for displaying a table data in drop down list?