How to set a default option in an ActiveDropDownList?

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?

Try setting the "Teamlead_id" of your model.

That worked. Thanks!!