1

I'm currently using the bootstrap_form 2.4.0 gem to make forms for my rails application. I'm at a point where i'm trying to create an annotation feature, where a person can go into the 'edit' page for an entry and decide which fields are valid or invalid by ticking or un-ticking a check-box next to that field.
So basically i need to create check-boxes in my 'edit' form that consist of only a glyph icon or an image.
I tried using the solution given by RemusGLS in this post: Is it posible to make an input checkbox a Bootstrap glyphicon? , which i modified to look how i want it to here
The problem is, this solution works for the basic form creation which is simply done by using the <input type="checkbox"> tag . and if i just use this method, it causes problems with the 'edit' page (as the check-boxes reset, which negates the whole point of the annotation ).
after inspecting the checkbox element that bootstrap form generate with the line

<%= f.check_box :blabla , label: "" %>

it seems that it generates this code

<label for="entry_blabla">
          <input name="entry[blabla]" type="hidden" value = "0" > 
          <input type="checkbox" value="1" checked="checked" name="entry[blabla]" id="entry_blabla" > 
        </label>`

that automatically changes based on the value of field (blabla in this case), i tried to use an if statement to simulate this code but i still cant integrate it with the solution to the icon checkboxes.
To sum it up in one sentence, I simply need the icon check-boxes solution (given here) to work with the Bootstrap form format (this one: <%= f.check_box :blabla , label: "" %> ).
Thank You.

Community
  • 1
  • 1
AmyAdamsIsBae
  • 41
  • 1
  • 7

1 Answers1

0

You can wrap the glyphicon by this way.

<%= f.label :blabla do %>
  <i class = "glyphicon glyphicon-ok" style="color:green;"></i>
  <i class='glyphicon glyphicon-remove' style="color:red;"></i>
<% end %>
  <%= f.check_box :blabla %>
Abid Iqbal
  • 753
  • 8
  • 22
  • it just shows everything, the two icons and then the checkbox with the default label (Blabla) (i have added the css to entries.scss) – AmyAdamsIsBae Jul 19 '16 at 10:53
  • is there a way where i can just user the normal form format with it ? i tried doing that and changing the name to `entry_blabla` and the id to `entry[blabla]` but it just doesn't go into the parameters. – AmyAdamsIsBae Jul 21 '16 at 08:35