mirror of
https://github.com/symbiote/silverstripe-gridfieldextensions.git
synced 2024-10-22 17:05:39 +02:00
Update code/GridFieldEditableColumns.php
Don't save ChildItem Values when a Column exists in many_many_extraFields Get values from many_many_extraFields instead of ChildItem
This commit is contained in:
parent
9be6bf26cf
commit
2f0e17ee58
@ -25,8 +25,14 @@ class GridFieldEditableColumns extends GridFieldDataColumns implements
|
||||
}
|
||||
|
||||
$fields = $this->getForm($grid, $record)->Fields();
|
||||
$value = $grid->getDataFieldValue($record, $col);
|
||||
$field = clone $fields->fieldByName($col);
|
||||
$list = $grid->getList();
|
||||
$extraData = array();
|
||||
if($list instanceof ManyManyList) {
|
||||
$extraData = $list->getExtraData($grid->getName(), $record->ID);
|
||||
}
|
||||
|
||||
$value = isset($extraData[$col]) ? $extraData[$col] : $grid->getDataFieldValue($record, $col);
|
||||
|
||||
if(!$field) {
|
||||
throw new Exception("Could not find the field '$col'");
|
||||
@ -71,16 +77,16 @@ class GridFieldEditableColumns extends GridFieldDataColumns implements
|
||||
}
|
||||
|
||||
$extra = array();
|
||||
|
||||
if($list instanceof ManyManyList) {
|
||||
$extra = array_intersect_key($fields, $list->getExtraFields());
|
||||
}
|
||||
|
||||
|
||||
$form->loadDataFrom($fields, Form::MERGE_CLEAR_MISSING);
|
||||
$form->saveInto($item);
|
||||
|
||||
$item->write();
|
||||
$list->add($item, $extra);
|
||||
|
||||
if($list instanceof ManyManyList) {
|
||||
$extra = array_intersect_key($fields, $list->getExtraFields());
|
||||
$list->add($item, $extra);
|
||||
} else {
|
||||
$item->write();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user