Form component visability base on select value not working.

This is the select
Forms\Components\Select::make('type')
->live()
->required()
->options(AssessmentTypes::class),
Forms\Components\Select::make('type')
->live()
->required()
->options(AssessmentTypes::class),
and this is the field I'm trying to show/hide
Forms\Components\TextInput::make('questions_count')
->visible(fn (Get $get): bool => $get('type') == AssessmentTypes::QUIZ || $get('type') == AssessmentTypes::EXAM )
->numeric(),
Forms\Components\TextInput::make('questions_count')
->visible(fn (Get $get): bool => $get('type') == AssessmentTypes::QUIZ || $get('type') == AssessmentTypes::EXAM )
->numeric(),
Can anyone tell me what I am doing wrong?
3 Replies
toeknee
toeknee2w ago
run a dd on the visible to see if the visibility is being hit
bardolf_6969
bardolf_6969OP2w ago
@toeknee the dd works so the visible condition is being parsed OK so after a bit of experimenting I found that if I set a default value on the SELECT field the reactivity works.
toeknee
toeknee2w ago
That would make sense for the first load

Did you find this page helpful?