From 8ca264b0b0f7965c5faf411db2f82c941cd03eff Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 1 May 2009 05:07:41 +0000 Subject: [PATCH] MINOR Merged from branches/2.3 git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@75875 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/TreeDropdownField.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/forms/TreeDropdownField.php b/forms/TreeDropdownField.php index e7968ee13..3a7501dea 100755 --- a/forms/TreeDropdownField.php +++ b/forms/TreeDropdownField.php @@ -99,6 +99,9 @@ HTML; echo substr(trim($tree), 4,-5); } + /** + * @return DataObject + */ public function getByKey($key) { if($this->keyField == 'ID') { return DataObject::get_by_id($this->sourceObject, $key); @@ -124,9 +127,13 @@ HTML; function performReadonlyTransformation() { $fieldName = $this->labelField; - $value = ($this->getByKey($this->value)) ? $this->getByKey($this->value)->$fieldName : ''; + if($this->value) { + $obj = ($this->getByKey($this->value)) ? $this->getByKey($this->value)->$fieldName : ''; + } else { + $obj = null; + } $source = array( - $this->value => $value + $this->value => $obj ); $field = new LookupField($this->name, $this->title, $source); $field->setValue($this->value);