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??
TIA,
rash*
Page 1 of 1
Yii-User And Building A User List How to get users for a dropdownlist
#2
Posted 13 January 2013 - 08:15 AM
I dont know if this what exactly you looking for
<?php echo CHtml::dropDownList('User', 'id', CHtml::listData(User::model()->findAll, 'id', 'name')); ?>
#3
Posted 13 January 2013 - 08:35 AM
alirz23, on 13 January 2013 - 08:15 AM, said:
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!
rash*
#4
Posted 13 January 2013 - 12:33 PM
It happens to most of us it was not a dumb question, thanks for the correction
Share this topic:
Page 1 of 1

Help












