silverstripe-framework/src/Forms/TreeDropdownField_Readonly.php

30 lines
713 B
PHP
Raw Normal View History

<?php
namespace SilverStripe\Forms;
class TreeDropdownField_Readonly extends TreeDropdownField
{
2016-11-29 00:31:16 +01:00
protected $readonly = true;
2016-11-29 00:31:16 +01:00
public function Field($properties = array())
{
$fieldName = $this->labelField;
if ($this->value) {
$keyObj = $this->objectForKey($this->value);
$obj = $keyObj ? $keyObj->$fieldName : '';
} else {
$obj = null;
}
2016-11-29 00:31:16 +01:00
$source = array(
$this->value => $obj
);
2016-11-29 00:31:16 +01:00
$field = new LookupField($this->name, $this->title, $source);
$field->setValue($this->value);
$field->setForm($this->form);
$field->dontEscape = true;
return $field->Field();
}
}