Radio

Options can be callable, collection or associative/flat array.
//associative array
$options = ['Wifi' => 'wf', 'Bluetooth' => 'bl', 'Ethernet' => 'eth'];
Radio::make('Radio')
->wire('defer') //wait with validation until next request.
->options($options)
->rules([Rule::in(array_values($options))])
->default('wf');//Radio where labels = key
$options = ['Wifi', 'Bluetooth', 'Ethernet'];
Radio::make('Radio')
->options($options)
->rules([Rule::in($options)])
->default('Wifi');//Livewire
public $radio;
public $options = ['Wifi' => 'wf', 'Bluetooth' => 'bl', 'Ethernet' => 'eth'];<x-tall-radio :field="Radio::blade('radio')
->options($options)
->default('wf')"
/>->options($options)
A list or flat
key => valuebasedArray,CollectionorClosure.OBSERVE: if you use a callable, it will be executed on EVERY re-render of the component! Maybe you should consider setting the
$optionsinmount() instead?You can use a component method that returns an array;
->options($this->someMethod())
Last updated
Was this helpful?