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();
|
$fields = $this->getForm($grid, $record)->Fields();
|
||||||
$value = $grid->getDataFieldValue($record, $col);
|
|
||||||
$field = clone $fields->fieldByName($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) {
|
if(!$field) {
|
||||||
throw new Exception("Could not find the field '$col'");
|
throw new Exception("Could not find the field '$col'");
|
||||||
@ -72,15 +78,15 @@ class GridFieldEditableColumns extends GridFieldDataColumns implements
|
|||||||
|
|
||||||
$extra = array();
|
$extra = array();
|
||||||
|
|
||||||
if($list instanceof ManyManyList) {
|
|
||||||
$extra = array_intersect_key($fields, $list->getExtraFields());
|
|
||||||
}
|
|
||||||
|
|
||||||
$form->loadDataFrom($fields, Form::MERGE_CLEAR_MISSING);
|
$form->loadDataFrom($fields, Form::MERGE_CLEAR_MISSING);
|
||||||
$form->saveInto($item);
|
$form->saveInto($item);
|
||||||
|
|
||||||
$item->write();
|
if($list instanceof ManyManyList) {
|
||||||
|
$extra = array_intersect_key($fields, $list->getExtraFields());
|
||||||
$list->add($item, $extra);
|
$list->add($item, $extra);
|
||||||
|
} else {
|
||||||
|
$item->write();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user