Display Drop Down List In View Values From Database


(Sivanthi071) #1

 $account = Account::model()->findAll();

Above line get id,name values from account table and store it as array in $account


$acclist = CHtml::listData($account, 'id', 'account');

Above line list values


  	echo $form->dropDownList($model, 'accid',$acclist, array('prompt'=>'Select Account'));

finally above line display dropdown list


(Softark) #2

[color="#006400"]/* Moved from "General Discussion for Yii 1.1.x" to "Tips, Snippets and Tutorials" */[/color]