mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
d27937f448
Fixed some whitespace git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@47725 467b73ca-7a2a-4603-9d3b-597d59a354a9
48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @package sapphire
|
|
* @subpackage forms
|
|
*/
|
|
|
|
/**
|
|
* Creates an editable field that displays members in a given group
|
|
*/
|
|
class EditableMemberListField extends EditableFormField {
|
|
|
|
static $has_one = array(
|
|
'Group' => 'Group'
|
|
);
|
|
|
|
static $singular_name = 'Member list field';
|
|
static $plural_name = 'Member list fields';
|
|
|
|
public function DefaultField() {
|
|
// return new TreeDropdownField( "Fields[{$this->ID}][GroupID]", 'Group' );
|
|
|
|
$groups = DataObject::get('Group');
|
|
|
|
foreach( $groups as $group )
|
|
$groupArray[$group->ID] = $group->Title;
|
|
|
|
return new DropdownField( "Fields[{$this->ID}][GroupID]", 'Group', $groupArray, $this->GroupID );
|
|
}
|
|
|
|
public function populateFromPostData( $data ) {
|
|
$this->GroupID = $data['GroupID'];
|
|
|
|
parent::populateFromPostData( $data );
|
|
}
|
|
|
|
function getFormField() {
|
|
return new DropdownField( $this->Name, $this->Title, Member::mapInGroups( $this->GroupID ) );
|
|
}
|
|
|
|
function getValueFromData( $data ) {
|
|
$value = $data[$this->Name];
|
|
|
|
$member = DataObject::get_one('Member', "Member.ID = {$value}");
|
|
return $member->getName();
|
|
}
|
|
}
|
|
?>
|