Skip to content

Commit c563f20

Browse files
committed
Allow sorting of lists by invisible columns
A previous bug fix applied here (18af35d) forced only visible columns to be sortable to prevent an error from occurring if someone sorts by a column that is then removed from the columns list. This change results in the same fix, but simply checks that the column is sortable (which would be false if the column no longer exists). This would allow columns that are invisible but are also sortable to still be used for sorting purposes. Fixes #796, #709 Refs: - octobercms/october#5227
1 parent d0d066f commit c563f20

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/backend/widgets/Lists.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ public function prepareQuery()
541541
/*
542542
* Apply sorting
543543
*/
544-
if (($sortColumn = $this->getSortColumn()) && !$this->showTree && in_array($sortColumn, array_keys($this->getVisibleColumns()))) {
544+
if (($sortColumn = $this->getSortColumn()) && !$this->showTree) {
545545
if (($column = array_get($this->allColumns, $sortColumn)) && $column->valueFrom) {
546546
$sortColumn = $this->isColumnPivot($column)
547547
? 'pivot_' . $column->valueFrom
@@ -1596,7 +1596,7 @@ public function getSortColumn()
15961596
return false;
15971597
}
15981598

1599-
if ($this->sortColumn !== null) {
1599+
if ($this->sortColumn !== null && $this->isSortable($this->sortColumn)) {
16001600
return $this->sortColumn;
16011601
}
16021602

0 commit comments

Comments
 (0)