Skip to content

Commit

Permalink
Merge pull request #104 from tractorcow/pulls/fix-save-on-sort
Browse files Browse the repository at this point in the history
BUG Ensure that sorting a row doesn't destroy any unsaved inline changes
  • Loading branch information
nyeholt committed Sep 14, 2015
2 parents b4a0c96 + f57278b commit 6845da4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions code/GridFieldOrderableRows.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 6845da4

Please sign in to comment.