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.

Data Model Questions

List members on current page in dropdown


Reply

2 Posts   1253 Views

Avatar
Mo

19 February 2010 at 4:20am Community Member, 509 Posts

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

13 March 2013 at 11:45pm (Last edited: 13 March 2013 11:48pm), Community Member, 90 Posts

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