From ea637b0ad58ede259b989574c2611c44b2f7652a Mon Sep 17 00:00:00 2001 From: Pieter Hollants Date: Mon, 23 Feb 2015 14:29:08 +0100 Subject: [PATCH] GridFieldOrderableRows: Prefix sort field with table name when sorting Prevents ambiguities when the GridField's underlying DataList uses a query that joins multiple tables having a sort field. --- code/GridFieldOrderableRows.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/GridFieldOrderableRows.php b/code/GridFieldOrderableRows.php index e8e96e9e..9d5a6bd0 100755 --- a/code/GridFieldOrderableRows.php +++ b/code/GridFieldOrderableRows.php @@ -190,7 +190,7 @@ public function getManipulatedData(GridField $grid, SS_List $list) { $sortterm = $this->extraSortFields.', '; } } - $sortterm .= $this->getSortField(); + $sortterm .= $this->getSortTable($list).'.'.$this->getSortField(); return $list->sort($sortterm); } else { return $list; @@ -226,7 +226,7 @@ public function handleReorder($grid, $request) { $sortterm = $this->extraSortFields.', '; } } - $sortterm .= $field; + $sortterm .= $this->getSortTable($list).'.'.$field; $items = $list->filter('ID', $ids)->sort($sortterm); // Ensure that each provided ID corresponded to an actual object.