silverstripe-framework/src/Forms/TreeDropdownField_Readonly.php

26 lines
667 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->getTitleField();
2016-11-29 00:31:16 +01:00
if ($this->value) {
$keyObj = $this->objectForKey($this->value);
$title = $keyObj ? $keyObj->$fieldName : '';
2016-11-29 00:31:16 +01:00
} else {
$title = null;
2016-11-29 00:31:16 +01:00
}
$source = [ $this->value => $title ];
$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();
}
}