Skip to content

Commit

Permalink
FIX ListboxField entwine submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewandante committed Jul 6, 2023
1 parent 4b22ab4 commit a03d0fd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Forms/ListboxField.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,17 +248,20 @@ public function getValueArray()
}

$canary = reset($validValues);
$targetType = gettype($canary);
if (is_array($value) && count($value) > 0) {
$first = reset($value);
// sanity check the values - make sure strings get strings, ints get ints etc
if (gettype($canary) !== gettype($first)) {
if ($targetType !== gettype($first)) {
$replaced = [];
foreach ($value as $item) {
if (!is_array($item)) {
$item = json_decode($item, true);
}

if (isset($item['Value'])) {
if ($targetType === gettype($item)) {
$replaced[] = $item;
} elseif (isset($item['Value'])) {
$replaced[] = $item['Value'];
}
}
Expand Down

0 comments on commit a03d0fd

Please sign in to comment.