Skip to content

Commit

Permalink
Merge pull request #1 from bedh29/bugfix-form-select-change
Browse files Browse the repository at this point in the history
form select small change
  • Loading branch information
sankarsuda authored Jul 15, 2024
2 parents e4ced51 + 1bee04c commit 3c96e35
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Components/FormSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,16 @@ public function nothingSelected(): bool

protected function normalizeOptions(array|Collection $options): Collection
{
if (!is_array($options)) {
$options = $options->toArray();
}

$isList = Arr::isList($options);

return collect($options)
->map(function ($value, $key) {
->map(function ($value, $key) use ($isList) {
// If the key is not numeric, we're going to assume this is the value.
if (!is_numeric($key)) {
if (!is_numeric($key) || !$isList) {
return [
$this->valueField => $key,
$this->labelField => $value,
Expand Down

0 comments on commit 3c96e35

Please sign in to comment.