I’m getting started with Stimulus/Turbo and trying to use it to filter out data on a page via a Form using GET.
When using checkboxes, an “off” value is not sent to the url. So if I turn the checkbox on, then I can’t turn it off on form submit because the request will now always have
I think this is due to the FormData object not having the value available, so when the request is pre-processed by Turbo, the url is merged with FormData, and it just keeps the old one.
I’ve gotten around it by adding a
<input type="hidden" value="0" name="showCompleted">when it is checked off via a Stimulus controller, but I was wondering if there was a better solution?
The preview loads the original checkbox on/off state, then changes it to the new one. It looks odd as you see the checkbox change.
I can disable the preview, but is there a recommended way to handle this case?