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

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@99579 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-02-22 04:36:36 +00:00
parent d68bbc2c01
commit ca3b8d5792
2 changed files with 5 additions and 20 deletions

View File

@ -308,15 +308,12 @@ class MemberTableField extends ComplexTableField {
function saveComplexTableField($data, $form, $params) {
$className = $this->sourceClass();
$childData = new $className();
// Needs to write before saveInto() to ensure the 'Groups' TreeMultiselectField saves
$childData->write();
$form->saveInto($childData);
$childData->write();
// 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']);
}
$closeLink = sprintf(
'<small><a href="' . $_SERVER['HTTP_REFERER'] . '" onclick="javascript:window.top.GB_hide(); return false;">(%s)</a></small>',
@ -452,19 +449,6 @@ class MemberTableField_Item extends ComplexTableField_Item {
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
*/

View File

@ -88,6 +88,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
);
// unset 'inlineadd' permission, we don't want inline addition
$memberList->setPermissions(array('show', 'edit', 'delete', 'add'));
$memberList->setRelationAutoSetting(false);
$fields = new FieldSet(
new TabSet(