2008-09-29 05:18:23 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Creates an editable field that displays members in a given group
|
2009-04-17 04:26:40 +02:00
|
|
|
*
|
|
|
|
* @package userforms
|
2008-09-29 05:18:23 +02:00
|
|
|
*/
|
|
|
|
class EditableMemberListField extends EditableFormField {
|
|
|
|
|
2009-05-06 05:34:40 +02:00
|
|
|
static $singular_name = 'Member List Field';
|
2009-04-27 06:32:47 +02:00
|
|
|
|
2009-05-06 05:34:40 +02:00
|
|
|
static $plural_name = 'Member List Fields';
|
2008-09-29 05:18:23 +02:00
|
|
|
|
2009-05-06 05:34:40 +02:00
|
|
|
function getFieldConfiguration() {
|
2009-04-27 08:17:02 +02:00
|
|
|
$groupID = ($this->getSetting('GroupID')) ? $this->getSetting('GroupID') : 0;
|
|
|
|
$groups = DataObject::get("Group");
|
|
|
|
if($groups) $groups = $groups->toDropdownMap('ID', 'Title');
|
|
|
|
$fields = new FieldSet(
|
|
|
|
new DropdownField("Fields[$this->ID][CustomSettings][GroupID]", _t('EditableFormField.GROUP', 'Group'), $groups, $groupID)
|
|
|
|
);
|
|
|
|
$fields->merge(parent::ExtraOptions());
|
|
|
|
|
|
|
|
return $fields;
|
|
|
|
}
|
2009-05-06 05:34:40 +02:00
|
|
|
|
2008-09-29 05:18:23 +02:00
|
|
|
function getFormField() {
|
2009-04-27 08:17:02 +02:00
|
|
|
return ($this->getSetting('GroupID')) ? new DropdownField( $this->Name, $this->Title, Member::mapInGroups($this->getSetting('GroupID'))) : false;
|
2008-09-29 05:18:23 +02:00
|
|
|
}
|
|
|
|
|
2009-04-27 06:32:47 +02:00
|
|
|
function getValueFromData($data) {
|
|
|
|
$value = Convert::raw2sql($data[$this->Name]);
|
2008-09-29 05:18:23 +02:00
|
|
|
|
|
|
|
$member = DataObject::get_one('Member', "Member.ID = {$value}");
|
2009-04-27 06:43:40 +02:00
|
|
|
return ($member) ? $member->getName() : "";
|
2008-09-29 05:18:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|