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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

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

List members on current page in dropdown


Go to End


2 Posts   2143 Views

Avatar
Mo

Community Member, 541 Posts

19 February 2010 at 4:20am

Hi All,

I am working on a new module, that I will release at some point in the near future (fingers crossed). I am having one annoying issue though. Basically, if I create my new page type, I want a DropdownField to appear that will list all members that are allowed to edit this page (set via the behaviour tab).

Currently I get all members listed in the dropdown by doing:

if ($member = DataObject::get('Member'))
		$member = $member->toDropdownMap('ID', 'FirstName', '(Select one)', true);

$fields->push(new DropdownField('AssignedToID', 'AssignedTo', $member));

I am guessing I need to add a filter to DataObject::get(), but what?

I could do a for loop on $this->EditorGroups(), but is that te best option?

Cheers,

Mo

Avatar
BenWu

Community Member, 97 Posts

13 March 2013 at 11:45pm

Edited: 13/03/2013 11:48pm

maybe a bit too old to reply:

$group = Group::get()->filter('code'=>'editor group name' )->first(); 
$members = $group->Members();
if ($member = DataObject::get('Member')) 
      $member = $member->toDropdownMap('ID', 'FirstName', '(Select one)', true);

$fields->push(new DropdownField('AssignedToID', 'AssignedTo', $member));