mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
68c3279fd9
Removed legacy entwine dead code Added soft-deprecation to label field
41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace SilverStripe\Forms;
|
|
|
|
class TreeMultiselectField_Readonly extends TreeMultiselectField
|
|
{
|
|
|
|
protected $readonly = true;
|
|
|
|
public function Field($properties = array())
|
|
{
|
|
// Build list of titles
|
|
$titleField = $this->getTitleField();
|
|
$items = $this->getItems();
|
|
$titleArray = [];
|
|
foreach ($items as $item) {
|
|
$titleArray[] = $item->$titleField;
|
|
}
|
|
$titleList = implode(", ", $titleArray);
|
|
|
|
// Build list of values
|
|
$itemIDs = [];
|
|
foreach ($items as $item) {
|
|
$itemIDs[] = $item->ID;
|
|
}
|
|
$itemIDsList = implode(",", $itemIDs);
|
|
|
|
// Readonly field for display
|
|
$field = new ReadonlyField($this->name . '_ReadonlyValue', $this->title);
|
|
$field->setValue($titleList);
|
|
$field->setForm($this->form);
|
|
|
|
// Store values to hidden field
|
|
$valueField = new HiddenField($this->name);
|
|
$valueField->setValue($itemIDsList);
|
|
$valueField->setForm($this->form);
|
|
|
|
return $field->Field() . $valueField->Field();
|
|
}
|
|
}
|