I have a form in Rails 4 where I want to use Bootstrap's radio buttons to set a binary value, instead of using a checkbox.
I'm using Bootstrap's example as a reference.
I want it to look like this:
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default">
<input type="radio" name="options" id="option1"> True
</label>
<label class="btn btn-default">
<input type="radio" name="options" id="option2"> False
</label>
</div>
http://jsfiddle.net/52VtD/3456/
But this is what I have so far (using HAML):
.btn-group{"data-toggle" => "buttons"}
%label.btn.btn-default
= f.radio_button :single_use, true
True
%label.btn.btn-default
= f.radio_button :single_use, false
False
Which produces:
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default">
<label class="radio" for="something_single_use_true">
<input id="something_single_use_true" name="something[single_use]" type="radio" value="true">
</label>
Single use
</label>
<label class="btn btn-default">
<label class="radio" for="something_single_use_false">
<input checked="checked" id="something_single_use_false" name="something[single_use]" type="radio" value="false">
</label>
Unlimited use
</label>
</div>
I'm also using rails-bootstrap-forms.
Update: Playing around in Chrome's DevTools, I can make the buttons look how I want them to (sans radio button) if I add the style display: none;
to the lines
<label class="radio" for="something_single_use_true">
...
<label class="radio" for="something_single_use_false">
But I'm not sure how to do that in HAML and using the Form Helper in Rails, because I believe those specific lines are generated for me.