diff --git a/code/GridFieldAddNewInlineButton.php b/code/GridFieldAddNewInlineButton.php index 3b776dd..47b6f17 100755 --- a/code/GridFieldAddNewInlineButton.php +++ b/code/GridFieldAddNewInlineButton.php @@ -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); diff --git a/code/GridFieldEditableColumns.php b/code/GridFieldEditableColumns.php index b69d4e6..996dbf9 100644 --- a/code/GridFieldEditableColumns.php +++ b/code/GridFieldEditableColumns.php @@ -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);