I managed to find a working solution using a hidden field where I’m using the onchange event to update the hidden field first. This sends the correct payload.
Ideally, I would like to use the s-switch directly.
s-switch (and s-checkbox) follow how the web handles this; you must set a value on the element if you want it to be something other than on when submitted.
I just tested and it looks like the correct value is updated inside the DOM.
It is no longer set to “on” when the s-switch is disabled, however, the param is still not sent to the server when the field is disabled.
I understand now that this is not a bug and just the standard way of how HTML works.
I just noticed that the default Rails checkbox <%= form.check_box :notifications %> outputs a hidden field automatically as the standard way of HTML is not to send any value when the input is unchecked.
<input name="<%= name %>" type="hidden" value="0" autocomplete="off">
<s-switch
<% if value %>checked<% end %>
name="<%= name %>"
label="<%= label %>">
</s-switch>
Thank you so much @Anthony_Frehner for your fix and your help to figure it out!