F
Filamentβ€’14mo ago
DevMike

checkbox list: Allow exactly one selection (like Radiobutton)

I have made a form with Checkbox lists, for it gives me the option to use relationships to pivot tables.
CheckboxList::make('data_option')
->label('Please select one option only!')
->relationship('table_with_data', 'title', function (Builder $query) use ($table_width_data_type) {
$query->where('type_id', $table_with_data_type->id); // which returns multiple records
})
CheckboxList::make('data_option')
->label('Please select one option only!')
->relationship('table_with_data', 'title', function (Builder $query) use ($table_width_data_type) {
$query->where('type_id', $table_with_data_type->id); // which returns multiple records
})
But instead of noticing the user via label to select only one option, I would like to only allow one option. (Just like Radiobutton, which can't be used in lack of relationship option or like SelectBox, which can't be used in Lack of BelongsToMany relationship.) Could be a good idea to implement an Option as "->SingleSelectionOnly()", which deselects all other options when one item being clicked.
2 Replies
toeknee
toekneeβ€’13mo ago
So with the repeater and select option we have maxItems, feel free to make a PR for it to checkbox πŸ™‚
DevMike
DevMikeOPβ€’13mo ago
Thank you for your input . I have to check that in manual first, for I don't know 'repeater', yet.
Want results from more Discord servers?
Add your server