mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX Fixed TreeMultiselectField/TreeDropdownField saving with 'unchanged' default values from constructor
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@99581 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
26ca64a579
commit
fcfccf6231
@ -160,6 +160,8 @@ class TreeDropdownField extends FormField {
|
|||||||
|
|
||||||
if($forceValues = $this->value) {
|
if($forceValues = $this->value) {
|
||||||
if(($values = preg_split('/,\s*/', $forceValues)) && count($values)) foreach($values as $value) {
|
if(($values = preg_split('/,\s*/', $forceValues)) && count($values)) foreach($values as $value) {
|
||||||
|
if(!is_numeric($value)) continue;
|
||||||
|
|
||||||
$obj->markToExpose($this->objectForKey($value));
|
$obj->markToExpose($this->objectForKey($value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,19 +39,21 @@ class TreeMultiselectField extends TreeDropdownField {
|
|||||||
// needed for errorMessage()
|
// needed for errorMessage()
|
||||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/LeftAndMain.js');
|
Requirements::javascript(SAPPHIRE_DIR . '/javascript/LeftAndMain.js');
|
||||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/TreeSelectorField.js");
|
Requirements::javascript(SAPPHIRE_DIR . "/javascript/TreeSelectorField.js");
|
||||||
|
|
||||||
// Any field values have priority over the relation getters
|
// Any field values have priority over the relation getters
|
||||||
if($this->value) {
|
if($this->value) {
|
||||||
$items = new DataObjectSet();
|
$items = new DataObjectSet();
|
||||||
$ids = explode(',', $this->value);
|
$ids = explode(',', $this->value);
|
||||||
foreach($ids as $id) {
|
foreach($ids as $id) {
|
||||||
|
if(!is_numeric($id)) continue;
|
||||||
|
|
||||||
$item = DataObject::get_by_id($this->sourceObject, $id);
|
$item = DataObject::get_by_id($this->sourceObject, $id);
|
||||||
if($item) $items->push($item);
|
if($item) $items->push($item);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$items = $this->getItems();
|
$items = $this->getItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($items && $items->Count()) {
|
if($items && $items->Count()) {
|
||||||
foreach($items as $item) {
|
foreach($items as $item) {
|
||||||
$titleArray[] =$item->Title;
|
$titleArray[] =$item->Title;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user