Skip to content

Select Option Group

tanthammar edited this page Apr 8, 2021 · 4 revisions

SelectOptGroup

Sponsors only

Please 💗 sponsor this package 🔗 in order to get access to this field. The documentation is available in the sponsor repository.

The $options are typically an Eloquent->groupBy() query, callable(), Collection or Array that returns the following structure

Example

$options = [
    'Swedish Cars' => [1 => 'Volvo', 2 => 'Saab'],
    'German Cars' => [3 => 'Mercedes', 4 => 'Audi']
];

SelectOptGroup::make('Select Option Group')
    ->options($options) //Callable, Collection or Array
    ->placeholder('Please select an option')
    ->default(3)
    ->fieldWidth('w-full sm:max-w-sm')
    ->wire('wire:model.defer')// if you don't want a network request on every click in the select
    ->rules(['nullable', Rule::in([1,2,3,4])]);

Clone this wiki locally