Permalink
Browse files

Merge pull request #26 from unclecheese/patch-1

BUGFIX: Use config layer to check for decorated $db fields
  • Loading branch information...
2 parents 7a9916b + 1575323 commit 3e4d5b525998cb434cf058a7ae349f351601227c @UndefinedOffset committed Jan 31, 2013
Showing with 9 additions and 6 deletions.
  1. +9 −6 code/forms/GridFieldSortableRows.php
@@ -149,12 +149,14 @@ protected function fixSortColumn($gridField, SS_List $dataList) {
$table=false;
$class=$gridField->getModelClass();
- if(!empty($class::$db) && array_key_exists($sortColumn, $class::$db)) {
+ $db = Config::inst()->get($class, "db", CONFIG::UNINHERITED);
+ if(!empty($db) && array_key_exists($sortColumn, $db)) {
$table=$class;
}else {
$classes=ClassInfo::ancestry($class, true);
foreach($classes as $class) {
- if(!empty($class::$db) && array_key_exists($sortColumn, $class::$db)) {
+ $db = Config::inst()->get($class, "db", CONFIG::UNINHERITED);
+ if(!empty($db) && array_key_exists($sortColumn, $db)) {
$table=$class;
break;
}
@@ -264,14 +266,15 @@ protected function saveGridRowSort(GridField $gridField, $data) {
}else {
//Find table containing the sort column
$table=false;
- $class=$gridField->getModelClass();
-
- if(!empty($class::$db) && array_key_exists($sortColumn, $class::$db)) {
+ $class=$gridField->getModelClass();
+ $db = Config::inst()->get($class, "db", CONFIG::UNINHERITED);
+ if(!empty($db) && array_key_exists($sortColumn, $db)) {
$table=$class;
}else {
$classes=ClassInfo::ancestry($class, true);
foreach($classes as $class) {
- if(!empty($class::$db) && array_key_exists($sortColumn, $class::$db)) {
+ $db = Config::inst()->get($class, "db", CONFIG::UNINHERITED);
+ if(!empty($db) && array_key_exists($sortColumn, $db)) {
$table=$class;
break;
}

0 comments on commit 3e4d5b5

Please sign in to comment.