Repeater with ->distinct() Checkbox, how to not require one be selected.
The Repeater works great, I have an 'is_default' column for each item, I am using ->distinct() to make sure only 1 can be set to default. However I also want to support not selecting a default option.
My issue is that if I try to save without checking one of the Repeater items as default it won't let me and shows a validation error "At least one is Default field must be selected."
Here is my current the "Is Default" field in my Repeater.
I have tried adding ->nullable(), ->required(false), ->optional()
I wan't the default checkbox to be optional, is there a way to make ->distinct() not require that one be selected?
3 Replies
I am still looking for a solution to this. Was considering not making it "distinct()" and just having a warning saying only check 1 default at most, ->distinct() is a better experience for the user though.
Looking at the code, I think this would need a PR to accept an attribute for distinct(). Feel free to submit and issue or a PR that would allow it.
Are you trying to make sure at least one checkbox is checked in your repeater