From e825a3b118b2730f5ef0e2be4dcefb817e696a54 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 1 May 2009 03:31:44 +0000 Subject: [PATCH] BUGFIX Checking for existing value on TreeDropdownField->performReadonlyTransformation() - this broke the ReadonlyTransformation on Translatable->updateCMSFields() for the new "ParentID" field in SiteTree->getCMSFields() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@75831 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 5e13532b2..70e97c9e5 100755 --- a/forms/TreeDropdownField.php +++ b/forms/TreeDropdownField.php @@ -98,6 +98,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); @@ -123,9 +126,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);