Yii Framework Forum: activeDropDownList with order by - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

activeDropDownList with order by Rate Topic: -----

#1 User is offline   nemo 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 142
  • Joined: 24-February 10

Posted 29 April 2010 - 11:51 AM

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' )); ?>
0

#2 User is offline   Jaz Manister 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 109
  • Joined: 27-October 09
  • Location:Rural Western New York, USA

Posted 29 April 2010 - 12:30 PM

View Postnemo, on 29 April 2010 - 11:51 AM, said:

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'));

0

#3 User is offline   nemo 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 142
  • Joined: 24-February 10

Posted 29 April 2010 - 12:42 PM

View PostJaz Manister, on 29 April 2010 - 12:30 PM, said:

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 :rolleyes:
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users