silverstripe-userforms/code/editor/EditableMemberListField.php

24 lines
660 B
PHP
Raw Normal View History

<?php
/**
* Creates an editable field that displays members in a given group
*
* @package userforms
*/
class EditableMemberListField extends EditableFormField {
static $singular_name = 'Member list field';
2009-04-27 06:32:47 +02:00
static $plural_name = 'Member list fields';
function getFormField() {
return ($this->getSetting($this->GroupID)) ? new DropdownField( $this->Name, $this->Title, Member::mapInGroups($this->getSetting($this->GroupID))) : false;
}
2009-04-27 06:32:47 +02:00
function getValueFromData($data) {
$value = Convert::raw2sql($data[$this->Name]);
$member = DataObject::get_one('Member', "Member.ID = {$value}");
return ($member) ? $member->getName() : "";
}
}
?>