BUGFIX Fixed TreeMultiselectField/TreeDropdownField saving with 'unchanged' default values from constructor (from r99581)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@99655 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-02-23 00:52:53 +00:00 committed by Sam Minnee
parent f44b9941ed
commit aca3bdf9b8
2 changed files with 6 additions and 2 deletions

View File

@ -204,6 +204,8 @@ class TreeDropdownField extends FormField {
if( isset($_REQUEST['forceValue']) || $this->value ) {
$forceValue = ( isset($_REQUEST['forceValue']) ? $_REQUEST['forceValue'] : $this->value);
if(($values = preg_split('/,\s*/', $forceValue)) && count($values)) foreach($values as $value) {
if(!is_numeric($value)) continue;
$obj->markToExpose($this->objectForKey($value));
}
}

View File

@ -54,19 +54,21 @@ class TreeMultiselectField extends TreeDropdownField {
Requirements::css(SAPPHIRE_DIR . '/javascript/tree/tree.css');
Requirements::css(SAPPHIRE_DIR . '/css/TreeDropdownField.css');
// Any field values have priority over the relation getters
if($this->value) {
$items = new DataObjectSet();
$ids = explode(',', $this->value);
foreach($ids as $id) {
if(!is_numeric($id)) continue;
$item = DataObject::get_by_id($this->sourceObject, $id);
if($item) $items->push($item);
}
} else {
$items = $this->getItems();
}
if($items && $items->Count()) {
foreach($items as $item) {
$titleArray[] =$item->Title;