Hey, I want to use orderby in CHtml::activeDropDownList. Can you tell me how to do that?
<?php echo CHtml::activeDropDownList($model,‘User_id’,CHtml::listData(CActiveRecord::model(‘User’)->findAll(),‘id’, ‘loginName’ )); ?>
Hey, I want to use orderby in CHtml::activeDropDownList. Can you tell me how to do that?
<?php echo CHtml::activeDropDownList($model,‘User_id’,CHtml::listData(CActiveRecord::model(‘User’)->findAll(),‘id’, ‘loginName’ )); ?>
Try using criteria
<?php
$criteria = new CDbCriteria;
$criteria->order = 'loginName'; //or whatever field
echo CHtml::activeDropDownList($model,'User_id',CHtml::listData(User::model()->findAll($criteria),'id','loginName'));
Thanx buddy, it’s working