mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #1718 from chillu/pulls/member-group-nested-editing
FIX Disallow group removal when member is edited in groups view
This commit is contained in:
commit
322b00ece0
@ -102,12 +102,18 @@ class Group extends DataObject {
|
||||
$config->getComponentByType('GridFieldDetailForm')
|
||||
->setValidator(new Member_Validator())
|
||||
->setItemEditFormCallback(function($form, $component) use($group) {
|
||||
$record = $form->getRecord();
|
||||
$groupsField = $form->Fields()->dataFieldByName('DirectGroups');
|
||||
if($groupsField) {
|
||||
// If new records are created in a group context,
|
||||
// set this group by default.
|
||||
$record = $form->getRecord();
|
||||
if($record && !$record->ID) {
|
||||
$groupsField = $form->Fields()->dataFieldByName('DirectGroups');
|
||||
if($groupsField) $groupsField->setValue($group->ID);
|
||||
$groupsField->setValue($group->ID);
|
||||
} elseif($record && $record->ID) {
|
||||
// TODO Mark disabled once chosen.js supports it
|
||||
// $groupsField->setDisabledItems(array($group->ID));
|
||||
$form->Fields()->replaceField('DirectGroups', $groupsField->performReadonlyTransformation());
|
||||
}
|
||||
}
|
||||
});
|
||||
$memberList = GridField::create('Members',false, $this->Members(), $config)->addExtraClass('members_grid');
|
||||
|
Loading…
Reference in New Issue
Block a user