Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Sep 14, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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