I have two model: test1 , test2 And an action in test1 :
public function active_widgets_list()
{
$widgets = SiteWidget::model()->find('status=:status', array(':status' => '1'));
return $widgets;
}
And I will show test1.tbl_1 rows as dropdown list in test2's view:
$list=CHtml::listData(SiteWidget::model()->active_widgets_list(), 'id', 'title');
echo $form->dropDownList($model,'widget_id', $list, array('empty' => 'Select Please'));
but down't work. i have just an empty dropdown.
You should be using findAll
instead of find
, since find
returns only a single active record with the specified condition.
$widgets = SiteWidget::model()->findAll('status=:status', array(':status' => '1'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With