Group
If you need a classic radio check the Radio component.
Default attributes
By default, it will look up for:
$object->idfor option value.$object->namefor option display label.
@php $users = App\Models\User::take(3)->get(); @endphp <x-group label="Select one" wire:model="selectedUser" :options="$users" hint="Pick one" />
Alternative attributes
Just set option-value and option-label representing the desired targets.
@php $users = App\Models\User::take(3)->get(); @endphp <x-group
label="Select one"
:options="$users"
wire:model="selectedUser2"
option-value="custom_key"
option-label="other_name"
class="[&:checked]:!btn-primary btn-sm" />
Disable options
You can disable options by setting the disabled attribute.
@php
$users = [
['id' => 1, 'name' => 'John'],
['id' => 2, 'name' => 'Doe'],
['id' => 3, 'name' => 'Mary', 'disabled' => true], // <-- This
['id' => 4, 'name' => 'Kate'],
];
@endphp
<x-group label="Select one" wire:model="selectedUser3" :options="$users" />
Made with
by
Robson Tenório and contributors.