silverstripe-framework/Forms/TreeDropdownField_Readonly.php
Damian Mooyman 8dd644d25d
API Namespace all classes
Namespace all templates
Move difflib and BBCodeParser2 to thirdparty
Remove deprecated API marked for removal in 4.0
2016-09-08 10:23:17 +12:00

30 lines
599 B
PHP

<?php
namespace SilverStripe\Forms;
class TreeDropdownField_Readonly extends TreeDropdownField
{
protected $readonly = true;
public function Field($properties = array())
{
$fieldName = $this->labelField;
if ($this->value) {
$keyObj = $this->objectForKey($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);
$field->dontEscape = true;
return $field->Field();
}
}