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
This commit is contained in:
Ingo Schommer 2009-05-01 03:31:44 +00:00 committed by Sam Minnee
parent 928e937ffc
commit e825a3b118

View File

@ -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);