sourceObject = $sourceObject; parent::__construct($name, $title); } function Field() { Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang'); Requirements::javascript(SAPPHIRE_DIR . "/javascript/TreeSelectorField.js"); $fieldName = $this->name; if($this->form) { $record = $this->form->getRecord(); if($record && $record->hasMethod($fieldName)) $items = $record->$fieldName(); } if($items) { foreach($items as $item) { $titleArray[] =$item->Title; $idArray[] = $item->ID; } if($titleArray) { $itemList = implode(", ", $titleArray); $value = implode(",", $idArray); } } $id = $this->id(); return << $itemList HTML; } /** * Save the results into the form */ function saveInto(DataObject $record) { $fieldName = $this->name; $saveDest = $record->$fieldName(); if($this->value) { $items = preg_split("/ *, */", trim($this->value)); } $saveDest->setByIDList($items); } /** * Return the site tree */ function gettree() { echo "