silverstripe-framework/src/Forms/TreeDropdownField_Readonly.php

29 lines
683 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())
{
2017-07-26 08:13:56 +02:00
$fieldName = $this->getLabelField();
2016-11-29 00:31:16 +01:00
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);
return $field->Field();
}
}