Merge pull request #200 from dhensby/pulls/1.4/field-callback-saved-record

FIX Forms now instantiate fields with correct record context on save
This commit is contained in:
Marcus 2017-08-03 11:53:19 +10:00 committed by GitHub
commit d6f2df0700
2 changed files with 3 additions and 3 deletions

View File

@ -147,7 +147,6 @@ class GridFieldAddNewInlineButton implements GridField_HTMLProvider, GridField_S
$editable = $grid->getConfig()->getComponentByType('GridFieldEditableColumns');
/** @var GridFieldOrderableRows $sortable */
$sortable = $grid->getConfig()->getComponentByType('GridFieldOrderableRows');
$form = $editable->getForm($grid, $record);
if(!singleton($class)->canCreate()) {
return;
@ -157,6 +156,7 @@ class GridFieldAddNewInlineButton implements GridField_HTMLProvider, GridField_S
$item = $class::create();
$extra = array();
$form = $editable->getForm($grid, $item);
$form->loadDataFrom($fields, Form::MERGE_CLEAR_MISSING);
$form->saveInto($item);

View File

@ -94,8 +94,6 @@ class GridFieldEditableColumns extends GridFieldDataColumns implements
/** @var GridFieldOrderableRows $sortable */
$sortable = $grid->getConfig()->getComponentByType('GridFieldOrderableRows');
$form = $this->getForm($grid, $record);
foreach($value[__CLASS__] as $id => $fields) {
if(!is_numeric($id) || !is_array($fields)) {
continue;
@ -107,6 +105,8 @@ class GridFieldEditableColumns extends GridFieldDataColumns implements
continue;
}
$form = $this->getForm($grid, $item);
$extra = array();
$form->loadDataFrom($fields, Form::MERGE_CLEAR_MISSING);