diff --git a/src/Fieldtypes/HasSelectOptions.php b/src/Fieldtypes/HasSelectOptions.php index 7e1289a3c4..802fd22b69 100644 --- a/src/Fieldtypes/HasSelectOptions.php +++ b/src/Fieldtypes/HasSelectOptions.php @@ -52,9 +52,8 @@ public function preProcessIndex($value) { $values = $this->preProcess($value); - $values = collect(is_array($values) ? $values : [$values]); - - return $values->map(function ($value) { + // NOTE: Null-coalescing into `[null]` as that matches old behaviour. + return collect($values ?? [null])->map(function ($value) { return $this->getLabel($value); })->all(); } @@ -67,9 +66,8 @@ public function preProcess($value) return []; } - $value = is_array($value) ? $value : [$value]; - - $values = collect($value)->map(function ($value) { + // NOTE: Null-coalescing into `[null]` as that matches old behaviour. + $values = collect($value ?? [null])->map(function ($value) { return $this->config('cast_booleans') ? $this->castFromBoolean($value) : $value; });