silverstripe-framework/src/Forms/TreeDropdownField_Readonly.php
Damian Mooyman 68c3279fd9
BUG Ensure readonly tree dropdown is safely encoded
Removed legacy entwine dead code
Added soft-deprecation to label field
2017-10-26 13:04:30 +13:00

26 lines
663 B
PHP

<?php
namespace SilverStripe\Forms;
class TreeDropdownField_Readonly extends TreeDropdownField
{
protected $readonly = true;
public function Field($properties = array())
{
$fieldName = $this->getTitleField();
if ($this->value) {
$keyObj = $this->objectForKey($this->value);
$title = $keyObj ? $keyObj->$fieldName : '';
} else {
$title = null;
}
$source = [ $this->value => $title ];
$field = new LookupField($this->name, $this->title, $source);
$field->setValue($this->value);
$field->setForm($this->form);
return $field->Field();
}
}