From d088354f46e39fa02de68fb0edc3ccbf143001a1 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Fri, 2 Aug 2019 16:17:42 +1200 Subject: [PATCH] FIX: Write relations when saving in grid-field item edit form Fixes https://github.com/silverstripe/silverstripe-framework/issues/9162 --- src/Forms/GridField/GridFieldDetailForm_ItemRequest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Forms/GridField/GridFieldDetailForm_ItemRequest.php b/src/Forms/GridField/GridFieldDetailForm_ItemRequest.php index 4b58032e4..02a86869d 100644 --- a/src/Forms/GridField/GridFieldDetailForm_ItemRequest.php +++ b/src/Forms/GridField/GridFieldDetailForm_ItemRequest.php @@ -610,9 +610,10 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler $this->record = $this->record->newClassInstance($newClassName); } - // Save form and any extra saved data into this dataobject + // Save form and any extra saved data into this dataobject. + // Set writeComponents = true to write has-one relations / join records $form->saveInto($this->record); - $this->record->write(); + $this->record->write(false, false, false, true); $this->extend('onAfterSave', $this->record); $extraData = $this->getExtraSavedData($this->record, $list);