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
|
||||
$ids = [];
|
||||
|
||||
if (is_string($value)) {
|
||||
$ids = preg_split("#\s*,\s*#", trim($value));
|
||||
} elseif (is_array($value)) {
|
||||
$ids = array_values($value);
|
||||
}
|
||||
|
||||
// Filter out empty strings
|
||||
$ids = array_filter($ids);
|
||||
|
||||
// No value
|
||||
if (empty($ids)) {
|
||||
return ArrayList::create();
|
||||
|
@ -340,5 +340,12 @@ class TreeMultiselectFieldTest extends SapphireTest
|
||||
[],
|
||||
$field->getItems()
|
||||
);
|
||||
|
||||
// Andle empty string none value
|
||||
$field->setValue('');
|
||||
$this->assertListEquals(
|
||||
[],
|
||||
$field->getItems()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user