BUG Fix PostgreSQL issue in TreeMultiselectField where field would try to filter list by a blank ID

This commit is contained in:
Maxime Rainville 2021-01-20 12:23:09 +13:00
parent 76ae5bc38a
commit 17c6f98ba2
2 changed files with 11 additions and 0 deletions

View File

@ -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();

View File

@ -340,5 +340,12 @@ class TreeMultiselectFieldTest extends SapphireTest
[],
$field->getItems()
);
// Andle empty string none value
$field->setValue('');
$this->assertListEquals(
[],
$field->getItems()
);
}
}