Force at least one checkbox to be checked for the check-all component #229
Replies: 5 comments
-
@seabasss not sure I follow what you mean force one checkbox to be checked. Can you explain that further, possibly with screenshots so it's clear what you mean? Thanks! |
Beta Was this translation helpful? Give feedback.
-
@joshhanley right now you can uncheck all checkboxes, but I want to make it so that at least one has to be checked at all times. Like a combo of radio buttons and checkboxes. You can never unselect all radio buttons. With the addition of multiple options checked, which already works :) |
Beta Was this translation helpful? Give feedback.
-
I forced the User to make a minimum selection via validation in the Livewire component. Could that approach resolve the issue for you ? |
Beta Was this translation helpful? Give feedback.
-
@lcallif I’m looking for a solution where the last remaining checkbox cannot be unchecked, disabling it if it’s the only one selected. I also want to allow the “check all” action but prevent “uncheck all.” Is handling this on the backend and rechecking the last box if none are selected the only alternative? I’m not sure how much control Alpine.js provides with flux yet, but adding some front-end logic would be ideal to avoid relying solely on server-side validation for this. |
Beta Was this translation helpful? Give feedback.
-
@seabasss ah right, makes sense. I'm going to convert this to a feature request for now. But yeah I would handle this on the backend for now. You should be able to hook into Flux from Alpine, but you'd have to do some digging to work that out. |
Beta Was this translation helpful? Give feedback.
-
For the Check-all component, is there any way to force at least one item to be checked?
Also, I noticed that the labels are not clickable in the demo, which they should be right?
Beta Was this translation helpful? Give feedback.
All reactions