2016-08-19 00:51:35 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\Forms;
|
|
|
|
|
|
|
|
class TreeDropdownField_Readonly extends TreeDropdownField
|
|
|
|
{
|
2016-11-29 00:31:16 +01:00
|
|
|
protected $readonly = true;
|
2016-08-19 00:51:35 +02:00
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
public function Field($properties = array())
|
|
|
|
{
|
2017-10-26 02:04:30 +02:00
|
|
|
$fieldName = $this->getTitleField();
|
2016-11-29 00:31:16 +01:00
|
|
|
if ($this->value) {
|
|
|
|
$keyObj = $this->objectForKey($this->value);
|
2017-10-26 02:04:30 +02:00
|
|
|
$title = $keyObj ? $keyObj->$fieldName : '';
|
2016-11-29 00:31:16 +01:00
|
|
|
} else {
|
2017-10-26 02:04:30 +02:00
|
|
|
$title = null;
|
2016-11-29 00:31:16 +01:00
|
|
|
}
|
2016-08-19 00:51:35 +02:00
|
|
|
|
2017-10-26 02:04:30 +02:00
|
|
|
$source = [ $this->value => $title ];
|
2018-10-24 01:11:57 +02:00
|
|
|
$field = LookupField::create($this->name, $this->title, $source);
|
2016-11-29 00:31:16 +01:00
|
|
|
$field->setValue($this->value);
|
|
|
|
$field->setForm($this->form);
|
|
|
|
return $field->Field();
|
|
|
|
}
|
2016-08-19 00:51:35 +02:00
|
|
|
}
|