F
Filament3mo ago
o.m

Conditionally display either checkbox or radio button in Repeater

Is it possible to display either radio button or checkbox in a repeater depending on what other field was selected? I did this but doesn't work
Repeater::make('options')
->label('Possible Answers')
->relationship('options')
->reorderable()
->schema([
Forms\Components\Radio::make('is_correct')
->label('Correct Answer')
->hidden(fn(callable $get) = > $get('../../type') !=
= 'single_choice'),
Checkbox::make('is_correct')
->label('Correct Answer')
->hidden(fn(callable $get) = > $get('../../type') !=
= 'multiple_choice'),
TextInput::make('label')->label('Answer Label')->required(true),
]),
Repeater::make('options')
->label('Possible Answers')
->relationship('options')
->reorderable()
->schema([
Forms\Components\Radio::make('is_correct')
->label('Correct Answer')
->hidden(fn(callable $get) = > $get('../../type') !=
= 'single_choice'),
Checkbox::make('is_correct')
->label('Correct Answer')
->hidden(fn(callable $get) = > $get('../../type') !=
= 'multiple_choice'),
TextInput::make('label')->label('Answer Label')->required(true),
]),
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?