Using bootstrap with radio_buttons on rails

Is it possible to use ie bootstrap switches:

<div class="btn-group" data-toggle="buttons-radio"> <button type="button" class="btn btn-primary">someValue</button> 

with the form for the rails? There is a radio_button method:

  <%= radio_button("object", "method", "someValue") %> 

but I could not stylize it. I did not know if there was anything to combine the two in order to give the radio button the start of the initial loading of the first fragment. Thanks Sam

+7
source share
2 answers

you can use this

 <div class="btn-group" data-toggle="buttons-radio"> <%= f.radio_button :brand, "ABC", :id=>"first", :style=>"display:none;" %> <label for="first" class="btn btn-primary">First</label> <%= f.radio_button :brand, "PQR", :id=>"second", :style=>"display:none;" %> <label for="second" class="btn btn-primary">Second</label> <%= f.radio_button :brand, "MNO", :id=>"third", :style=>"display:none;" %> <label for="third" class="btn btn-primary">Third</label> </div> 

here you need to provide an identifier for the radio exchange and assign a label to it using the attribute in the tag tag. So that he can indicate the appropriate switch.

+6
source

Correct me if I am wrong, but if you set the value attribute of the label in the same way as the radio button parameters, it will work the same way as assigning an identifier to the corresponding radio button

 <%= f.radio_button :brand, "MNO", :style=>"display:none;" %> <%= f.label :brand, "Third", value => "MNO", class="btn btn-primary" %> 
0
source

All Articles