From ff1e605de9a71e87c1052e272df51ebc103cb621 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Thu, 4 Feb 2010 03:45:02 +0000 Subject: [PATCH] BUGFIX: Don't default to sorted descending if you already have a different column sorted ascending. (from r96061) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@98134 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/TableListField.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/forms/TableListField.php b/forms/TableListField.php index 78e1a0d9e..a716f2917 100755 --- a/forms/TableListField.php +++ b/forms/TableListField.php @@ -320,11 +320,13 @@ JS $sortLink = $this->Link(); $sortLink = HTTP::setGetVar("ctf[{$this->Name()}][sort]", $fieldName, $sortLink); - // Apply sort direction - $dir = isset($_REQUEST['ctf'][$this->Name()]['dir']) ? $_REQUEST['ctf'][$this->Name()]['dir'] : null; - $dir = trim(strtolower($dir)); - $newDir = ($dir == 'desc') ? null : 'desc'; - $sortLink = HTTP::setGetVar("ctf[{$this->Name()}][dir]", Convert::raw2xml($newDir), $sortLink); + // Apply sort direction to the current sort field + if(!empty($_REQUEST['ctf'][$this->Name()]['sort']) && ($_REQUEST['ctf'][$this->Name()]['sort'] == $fieldName)) { + $dir = isset($_REQUEST['ctf'][$this->Name()]['dir']) ? $_REQUEST['ctf'][$this->Name()]['dir'] : null; + $dir = trim(strtolower($dir)); + $newDir = ($dir == 'desc') ? null : 'desc'; + $sortLink = HTTP::setGetVar("ctf[{$this->Name()}][dir]", Convert::raw2xml($newDir), $sortLink); + } if(isset($_REQUEST['ctf'][$this->Name()]['search']) && is_array($_REQUEST['ctf'][$this->Name()]['search'])) { foreach($_REQUEST['ctf'][$this->Name()]['search'] as $parameter => $value) {