Yii Framework Forum: Yii-User And Building A User List - Yii Framework Forum

Jump to content

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

Yii-User And Building A User List How to get users for a dropdownlist Rate Topic: -----

#1 User is offline   rashmani 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 26-August 11

Posted 13 January 2013 - 07:39 AM

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*
0

#2 User is offline   alirz23 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,032
  • Joined: 08-August 12
  • Location:Durban, South Africa

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

1

#3 User is offline   rashmani 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 26-August 11

Posted 13 January 2013 - 08:35 AM

View Postalirz23, 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*
0

#4 User is offline   alirz23 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,032
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 13 January 2013 - 12:33 PM

It happens to most of us it was not a dumb question, thanks for the correction
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