I’m using CHtml::listData to populate a User drop down list. The User model has id and loginName attributes.
My drop down list is specified as follows:
$criteria = new CDbCriteria;
$criteria->addCondition(‘loginName !=""’);
$criteria->order = ‘loginName’;
echo CHtml::activeDropDownList($model,‘Teamlead_id’,CHtml::listData(User::model()->findAll($criteria),‘id’,‘loginName’), array());
I would like to have the Yii::app()->User->id pre-selected in this drop down list. Can I specify that somehow in the htmlOptions array? Or is there another way?