From f57278b11af5b536f9acb9cf6fc03dedb0b9ec0c Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Mon, 14 Sep 2015 14:53:49 +1200 Subject: [PATCH] BUG Ensure that sorting a row doesn't destroy any unsaved inline changes --- code/GridFieldOrderableRows.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/code/GridFieldOrderableRows.php b/code/GridFieldOrderableRows.php index bb8a1ecb..0be7897c 100755 --- a/code/GridFieldOrderableRows.php +++ b/code/GridFieldOrderableRows.php @@ -199,6 +199,10 @@ public function getManipulatedData(GridField $grid, SS_List $list) { /** * Handles requests to reorder a set of IDs in a specific order. + * + * @param GridField $grid + * @param SS_HTTPRequest $request + * @return SS_HTTPResponse */ public function handleReorder($grid, $request) { $list = $grid->getList(); @@ -234,6 +238,12 @@ public function handleReorder($grid, $request) { $this->httpError(404); } + // Save any un-comitted changes to the gridfield + if(($form = $grid->getForm()) && ($record = $form->getRecord()) ) { + $form->loadDataFrom($request->requestVars(), true); + $grid->saveInto($record); + } + // Populate each object we are sorting with a sort value. $this->populateSortValues($items);