Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

List of members as select field


Reply


3 Posts   1332 Views

Avatar
Jatinder

Community Member, 23 Posts

8 July 2010 at 12:42am

Hello,

I am developing a custom module and have added a custom page type. I want to add a member with each page of this custom page type.

That is, when the admin creates a page, he should be able to select a member from a dropdown list of members for a specific group.

How do I go about this?

Thanks,
Jatinder Singh Thind

Avatar
Devlin

Community Member, 217 Posts

8 July 2010 at 3:25am

$specificGroups = array(1,2,3);
$Group = new Group();
$Members = $Group->Members(
               $limit = '',
               $offset = '',
               $filter = "`Group_Members`.GroupID IN ( ".implode(", ",$specificGroups)." )",
               $sort = 'Member.Email',
               $join = ''
            );
new DropdownField('Member1','Member 1',$Members->toDropdownMap('ID'),$this->Member1);

Avatar
Jatinder

Community Member, 23 Posts

8 July 2010 at 6:14pm

Thank you for the response. I will try that out.