BUGFIX: removing permissions before re-applying them (previously it just removed the components on the relation which resulted in permissions having GroupID set to 0) (from r94810)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@95624 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2009-12-16 05:43:20 +00:00
parent 5be077cd83
commit 14c66fb2f8

View File

@ -122,7 +122,13 @@ class PermissionCheckboxSetField extends CheckboxSetField {
function saveInto(DataObject $record) {
$fieldname = $this->name;
$managedClass = $this->managedClass;
$record->$fieldname()->removeAll();
// remove all permissions and re-add them afterwards
$permissions = $record->$fieldname();
foreach ( $permissions as $permission ) {
$permission->delete();
}
if($fieldname && $record && ($record->has_many($fieldname) || $record->many_many($fieldname))) {
$idList = array();
if($this->value) foreach($this->value as $id => $bool) {