2016-08-19 10:51:35 +12:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\Forms;
|
|
|
|
|
|
|
|
class TreeMultiselectField_Readonly extends TreeMultiselectField
|
|
|
|
{
|
|
|
|
|
2016-11-29 12:31:16 +13:00
|
|
|
protected $readonly = true;
|
2016-08-19 10:51:35 +12:00
|
|
|
|
2016-11-29 12:31:16 +13:00
|
|
|
public function Field($properties = array())
|
|
|
|
{
|
|
|
|
$titleArray = $itemIDs = array();
|
|
|
|
$titleList = $itemIDsList = "";
|
|
|
|
if ($items = $this->getItems()) {
|
|
|
|
foreach ($items as $item) {
|
|
|
|
$titleArray[] = $item->Title;
|
|
|
|
}
|
|
|
|
foreach ($items as $item) {
|
|
|
|
$itemIDs[] = $item->ID;
|
|
|
|
}
|
|
|
|
if ($titleArray) {
|
|
|
|
$titleList = implode(", ", $titleArray);
|
|
|
|
}
|
|
|
|
if ($itemIDs) {
|
|
|
|
$itemIDsList = implode(",", $itemIDs);
|
|
|
|
}
|
|
|
|
}
|
2016-08-19 10:51:35 +12:00
|
|
|
|
2016-11-29 12:31:16 +13:00
|
|
|
$field = new ReadonlyField($this->name . '_ReadonlyValue', $this->title);
|
|
|
|
$field->setValue($titleList);
|
|
|
|
$field->setForm($this->form);
|
2016-08-19 10:51:35 +12:00
|
|
|
|
2016-11-29 12:31:16 +13:00
|
|
|
$valueField = new HiddenField($this->name);
|
|
|
|
$valueField->setValue($itemIDsList);
|
|
|
|
$valueField->setForm($this->form);
|
2016-08-19 10:51:35 +12:00
|
|
|
|
2016-11-29 12:31:16 +13:00
|
|
|
return $field->Field() . $valueField->Field();
|
|
|
|
}
|
2016-08-19 10:51:35 +12:00
|
|
|
}
|