Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » List members on current page in dropdown

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

Page: 1
Go to End
Author Topic: 1236 Views
  • Mo
    Avatar
    Community Member
    508 Posts

    List members on current page in dropdown Link to this post

    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

  • BenWu
    Avatar
    Community Member
    90 Posts

    Re: List members on current page in dropdown Link to this post

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

    1236 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.