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)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@96765 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
c51a945732
commit
91bb2e56b6
@ -204,5 +204,34 @@ class TreeDropdownField extends FormField {
|
||||
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