BUG Ensure that sorting a row doesn't destroy any unsaved inline changes

This commit is contained in:
Damian Mooyman 2015-09-14 14:53:49 +12:00
parent b4a0c9618b
commit f57278b11a
1 changed files with 10 additions and 0 deletions

View File

@ -199,6 +199,10 @@ class GridFieldOrderableRows extends RequestHandler implements
/**
* 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 @@ class GridFieldOrderableRows extends RequestHandler implements
$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);