Default selection for radio element - not working!

class FormPaySchedule extends Component implements Forms\Contracts\HasForms { use Forms\Concerns\InteractsWithForms; public $title; public $type_pay_schedule; public $pay_schedule; protected function getFormSchema(): array { return[ Wizard::make([ Wizard\Step::make('paso 1') ->schema([ Card::make([ Radio::make('type_pay_schedule')->label('') ->options([ 'option1' => 'by employee', 'option2' => 'everyone employees', ]) ->descriptions([ 'option1' => 'A', 'option2' => 'B', ]) ->default('option1') ->required(), ]) ]), ...
5 Replies
Patrick Boivin
I'm using something like this in the cases where default() doesn't work:
->afterStateHydrated(function ($state, $component) {
if (!$state) {
$component->state('option1');
}
})
->afterStateHydrated(function ($state, $component) {
if (!$state) {
$component->state('option1');
}
})
Iliyas M
Iliyas M2y ago
default()
default()
will not work in edit record page
Ander
AnderOP2y ago
thanks you
LeandroFerreira
Add:
public function mount(): void
{
$this->form->fill();
}
public function mount(): void
{
$this->form->fill();
}
Then default() will work
Ander
AnderOP2y ago
thanks to all

Did you find this page helpful?