From b5a5500ff4a98fc89b213f4c9d30e595f4151fe1 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 2 Nov 2009 06:27:00 +0000 Subject: [PATCH] BUGFIX: Make DataObject::dbObject('ClassName') work. git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@90632 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/DataObject.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/model/DataObject.php b/core/model/DataObject.php index d46a2ec3f..5231a2652 100755 --- a/core/model/DataObject.php +++ b/core/model/DataObject.php @@ -2372,6 +2372,11 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity } else if(preg_match('/ID$/', $fieldName) && $this->has_one(substr($fieldName,0,-2))) { $val = (isset($this->record[$fieldName])) ? $this->record[$fieldName] : null; return DBField::create('ForeignKey', $val, $fieldName, $this); + + // Special case for ClassName + } else if($fieldName == 'ClassName') { + $val = get_class($this); + return DBField::create('Varchar', $val, $fieldName, $this); } }