mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUG Fix PostgreSQL issue in TreeMultiselectField where field would try to filter list by a blank ID
This commit is contained in:
parent
76ae5bc38a
commit
17c6f98ba2
@ -149,12 +149,16 @@ class TreeMultiselectField extends TreeDropdownField
|
|||||||
|
|
||||||
// Parse ids from value string / array
|
// Parse ids from value string / array
|
||||||
$ids = [];
|
$ids = [];
|
||||||
|
|
||||||
if (is_string($value)) {
|
if (is_string($value)) {
|
||||||
$ids = preg_split("#\s*,\s*#", trim($value));
|
$ids = preg_split("#\s*,\s*#", trim($value));
|
||||||
} elseif (is_array($value)) {
|
} elseif (is_array($value)) {
|
||||||
$ids = array_values($value);
|
$ids = array_values($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filter out empty strings
|
||||||
|
$ids = array_filter($ids);
|
||||||
|
|
||||||
// No value
|
// No value
|
||||||
if (empty($ids)) {
|
if (empty($ids)) {
|
||||||
return ArrayList::create();
|
return ArrayList::create();
|
||||||
|
@ -340,5 +340,12 @@ class TreeMultiselectFieldTest extends SapphireTest
|
|||||||
[],
|
[],
|
||||||
$field->getItems()
|
$field->getItems()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Andle empty string none value
|
||||||
|
$field->setValue('');
|
||||||
|
$this->assertListEquals(
|
||||||
|
[],
|
||||||
|
$field->getItems()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user