F
Filament17mo ago
Ander

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
Patrick Boivin17mo ago
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 M17mo ago
default()
default()
will not work in edit record page
Ander
AnderOP17mo ago
thanks you
LeandroFerreira
LeandroFerreira17mo ago
Add:
public function mount(): void
{
$this->form->fill();
}
public function mount(): void
{
$this->form->fill();
}
Then default() will work
Ander
AnderOP17mo ago
thanks to all
Want results from more Discord servers?
Add your server