BUGFIX TreeMultiselectField_Readonly now posts the correct value to the server (from r97100)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@98150 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-02-04 04:29:21 +00:00
parent ca4030df12
commit 5039273e75

View File

@ -111,16 +111,23 @@ class TreeMultiselectField_Readonly extends TreeMultiselectField {
protected $readonly = true;
function Field() {
$titleArray = array();
$titleList = 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);
}
$field = new ReadonlyField($this->name, $this->title);
$field = new ReadonlyField($this->name.'_ReadonlyValue', $this->title);
$field->setValue($titleList);
$field->setForm($this->form);
return $field->Field();
$valueField = new HiddenField($this->name);
$valueField->setValue($itemIDsList);
$valueField->setForm($this->form);
return $field->Field().$valueField->Field();
}
}