Yii-User And Building A User List

Hi there,

I feel dumb but after hourse of searching and reading I need to ask around.

I’m not able to figure out how to build a list of users for a dropdownlist. I’m using yii-user (with yii-rights) and everything’s working perfectly. I do use user profile’s fields and user relations within other models, but I can’t understand how to build such a dropdownlist.

What am I missing??



I dont know if this what exactly you looking for

<?php echo CHtml::dropDownList('User', 'id', CHtml::listData(User::model()->findAll, 'id', 'name')); ?>

I told you I’m dumb… I didn’t even try that, assuming it wouldn’t have worked!

But it does, of course! Thanks a lot (for confirming my dumbness)!

Btw, I believe the code has to be:

<?php echo CHtml::dropDownList('User', 'id', CHtml::listData(User::model()->findAll(), 'id', 'username')); ?>

where it’s ‘findAll()’ instead of ‘findAll’ and ‘username’ (because I use yii-user, and unless you want to show other profile fields or combination of them) instead of ‘name’.

Thanks alirz23!


It happens to most of us it was not a dumb question, thanks for the correction