Skip to content

Commit

Permalink
BUG Fix PostgreSQL issue in TreeMultiselectField where field would tr…
Browse files Browse the repository at this point in the history
…y to filter list by a blank ID
  • Loading branch information
maxime-rainville committed Jan 19, 2021
1 parent 76ae5bc commit 17c6f98
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Forms/TreeMultiselectField.php
Expand Up @@ -149,12 +149,16 @@ public function getItems()

// 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();
Expand Down
7 changes: 7 additions & 0 deletions tests/php/Forms/TreeMultiselectFieldTest.php
Expand Up @@ -340,5 +340,12 @@ function ($folder) {
[],
$field->getItems()
);

// Andle empty string none value
$field->setValue('');
$this->assertListEquals(
[],
$field->getItems()
);
}
}

0 comments on commit 17c6f98

Please sign in to comment.