Closed xorock closed 1 year ago
This will be fixed in the next release. See #89
Hi @rawilk
Is this still a known issue, as using Model::pluck('name', 'id')
to get an ID => Name associative array shows just the names in the value and text of the options.
I've tried using ->toArray()
to return an actual array rather than a collection but it still doesn't work?
<x-select name="client_id" wire:model="client_id" :options="$clients">
<option value="">-- Select --</option>
</x-select>
If I swap the params on pluck, it shows the ID in the text and Name in the value (Model::pluck('id', 'name')
)
Laravel Form Components Version
v8.0
Laravel Version
v10.3
Alpine Version
No response
Bug description
Hi, I am trying to use a simple numeric array in a select field.
<x-tw-select name="filter[active]" :options="[0 => 'aa', 1 => 'bb']">
but I'm getting error "foreach() argument must be of type array|object, string given". This is because first element 'aa' is threated as optgroup in https://github.com/rawilk/laravel-form-components/blob/main/resources/views/components/inputs/partials/select-option.blade.php#L1 $children here https://github.com/rawilk/laravel-form-components/blob/main/src/Concerns/GetsSelectOptionProperties.php#L55 is not empty (aa) and thus method returns true. Component then tries to iterate over string value and error is thrown.Steps to reproduce
No response
Relevant log output
No response