mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Fixed readonly form of TreeDropdownField when field is made readonly before value is set (from r94608) (from r96765)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102394 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
5bcfbe6622
commit
7eb4e8ef83
@ -206,5 +206,34 @@ class TreeDropdownField extends FormField {
|
|||||||
return DataObject::get_one($this->sourceObject, "\"{$this->keyField}\" = '" . Convert::raw2sql($key) . "'");
|
return DataObject::get_one($this->sourceObject, "\"{$this->keyField}\" = '" . Convert::raw2sql($key) . "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes this field to the readonly field.
|
||||||
|
*/
|
||||||
|
function performReadonlyTransformation() {
|
||||||
|
return new TreeDropdownField_Readonly($this->name, $this->title, $this->sourceObject, $this->keyField, $this->labelField);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TreeDropdownField_Readonly extends TreeDropdownField {
|
||||||
|
protected $readonly = true;
|
||||||
|
|
||||||
|
function Field() {
|
||||||
|
$fieldName = $this->labelField;
|
||||||
|
if($this->value) {
|
||||||
|
$keyObj = $this->getByKey($this->value);
|
||||||
|
$obj = $keyObj ? $keyObj->$fieldName : '';
|
||||||
|
} else {
|
||||||
|
$obj = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$source = array(
|
||||||
|
$this->value => $obj
|
||||||
|
);
|
||||||
|
|
||||||
|
$field = new LookupField($this->name, $this->title, $source);
|
||||||
|
$field->setValue($this->value);
|
||||||
|
$field->setForm($this->form);
|
||||||
|
return $field->Field();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user