ENHANCEMENT Saving group relations on SecurityAdmin->EditForm()/RootForm() through TreeMultiselectField instead of hidden 'Group'/'GroupID' values (from r99579)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@99690 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-02-23 03:36:02 +00:00 committed by Sam Minnee
parent 7f3c14784f
commit f47e12f726

View File

@ -308,15 +308,11 @@ class MemberTableField extends ComplexTableField {
$className = $this->sourceClass(); $className = $this->sourceClass();
$childData = new $className(); $childData = new $className();
$form->saveInto($childData); // Needs to write before saveInto() to ensure the 'Groups' TreeMultiselectField saves
$childData->write(); $childData->write();
// Only write group if no specific assignments have been set $form->saveInto($childData);
if(isset($data['Groups']) && $data['Groups']) { $childData->write();
$childData->Groups()->setByIDList(explode(',', $data['Groups']));
} else {
$childData->Groups()->add($data['GroupID']);
}
$closeLink = sprintf( $closeLink = sprintf(
'<small><a href="' . $_SERVER['HTTP_REFERER'] . '" onclick="javascript:window.top.GB_hide(); return false;">(%s)</a></small>', '<small><a href="' . $_SERVER['HTTP_REFERER'] . '" onclick="javascript:window.top.GB_hide(); return false;">(%s)</a></small>',
@ -452,19 +448,6 @@ class MemberTableField_Item extends ComplexTableField_Item {
class MemberTableField_ItemRequest extends ComplexTableField_ItemRequest { class MemberTableField_ItemRequest extends ComplexTableField_ItemRequest {
function saveComplexTableField($data, $form, $request) {
parent::saveComplexTableField($data, $form, $request);
$childData = $this->dataObj();
// Only write group if no specific assignments have been set
if(isset($data['Groups']) && $data['Groups']) {
$childData->Groups()->setByIDList(explode(',', $data['Groups']));
} else {
$childData->Groups()->add($data['GroupID']);
}
}
/** /**
* Deleting an item from a member table field should just remove that member from the group * Deleting an item from a member table field should just remove that member from the group
*/ */