From 30517119d43e70c565f5a082fc9718f03fcc8ab6 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Sun, 31 May 2009 11:07:28 +0000 Subject: [PATCH] ENHANCEMENT: Improve TableListField query generation, so that it checks whether the DataObject has a database field, rather than just checking to see if it *doesn't* have a field or method. git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@78153 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/TableListField.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/forms/TableListField.php b/forms/TableListField.php index 266ea6eeb..a22b51da0 100755 --- a/forms/TableListField.php +++ b/forms/TableListField.php @@ -458,13 +458,12 @@ JS $query->select[] = "{$baseClass}.ClassName AS \"RecordClassName\""; } else { $query = singleton($this->sourceClass)->extendedSQL($this->sourceFilter(), $this->sourceSort, null, $this->sourceJoin); - + // Add more selected fields if they are from joined table. - - $SNG = singleton($this->sourceClass); - foreach($this->FieldList() as $k=>$title){ - if(!$SNG->hasField($k) && !$SNG->hasMethod('get' . $k) && !$SNG->hasMethod($k) && !strpos($k, ".")) + foreach($this->FieldList() as $k => $title) { + if(!strpos($k, '.') && singleton($this->sourceClass)->hasDatabaseField($k)) { $query->select[] = "\"$k\""; + } } }