Reputation: 846
I need to toggle boolean value through one checkbox
Right now I have two checkboxes one set to true and the other set to false
When someone clicks on wither button it set an event on the submit button to submit the new value.
<%= form_with(model: @project, local: true) do |form| %>
<div>
<div id="info_false">
<%= label :access_rights, "Pending", value: false %>
<%= form.radio_button :build_one, false, :checked => true, :value => false, id: "build_one_1" %>
</div>
<div id="info_true">
<%= label :access_rights, "Completed", value: true %>
<%= form.radio_button :build_one, true, :value => true, id: "build_one_2" %>
</div>
</div>
<div class="actions">
<%= form.submit id: "build_one", :style => "visibility:hidden;", data: { confirm: "Are you sure?"} %>
</div>
Upvotes: 0
Views: 1338
Reputation: 3168
Those are radio
buttons not checkboxes
, I'm not sure if I understand what you are looking for but you can toggle between true
or false
values for radio buttons in a simple way
Demo https://jsfiddle.net/ff9ccqx5/1/
Upvotes: 1