silverstripe-userforms/code/model/formfields/EditableMemberListField.php
edchipman@gmail.com 5de26cd897 Replaced all instances of new FieldSet() with new FieldList()
Replaced the complex table field used for editing the email recipients with GridField

Replaced instances of SAPPHIRE_DIR with FRAMEWORK_DIR

Replaced instances of sapphire/ in css and templates with framework/

Re-organized tabs on user defined form so they are top level

Replaced calls to toDropdownMap() with map()

Renamed getCMSFields_forPopup() top getCMSFields()
2012-05-07 17:41:29 +12:00

48 lines
1.1 KiB
PHP

<?php
/**
* Creates an editable field that displays members in a given group
*
* @package userforms
*/
class EditableMemberListField extends EditableFormField {
static $singular_name = 'Member List Field';
static $plural_name = 'Member List Fields';
function getFieldConfiguration() {
$groupID = ($this->getSetting('GroupID')) ? $this->getSetting('GroupID') : 0;
$groups = DataObject::get("Group");
if($groups) $groups = $groups->toDropdownMap('ID', 'Title');
$fields = new FieldList(
new DropdownField("Fields[$this->ID][CustomSettings][GroupID]", _t('EditableFormField.GROUP', 'Group'), $groups, $groupID)
);
return $fields;
}
function getFormField() {
if ($this->getSetting('GroupID')) {
$members = Member::mapInGroups($this->getSetting('GroupID'));
return new DropdownField($this->Name, $this->Title, $members);
}
return false;
}
function getValueFromData($data) {
if(isset($data[$this->Name])) {
$value = Convert::raw2sql($data[$this->Name]);
$member = DataObject::get_one('Member', "Member.ID = {$value}");
return ($member) ? $member->getName() : "";
}
return false;
}
}