Reputation:
I have a code of checkbox below in ruby on rails:
<%= check_box(:Monday,{:id => "Monday",:value => "Monday"}) %>
But, it shows only the checkbox but not shows its text i.e "Monday".
So what should I do to display the text of checkbox, kindly suggest me, waiting for reply. Thanks
Upvotes: 1
Views: 18058
Reputation: 76784
You need to use a label:
<%= form_tag your_path do %>
<%= label "Day" %>
<%= check_box "Monday", "yes" %>
<% end %>
Upvotes: 0
Reputation: 3008
Have you read this?
http://apidock.com/rails/v4.0.2/ActionView/Helpers/FormTagHelper/check_box_tag
Either you use the check_box_tag or the f.check_box inside a form builder, plus you have to add a label to display it.
The construct you are using just generate the <input type="checkbox" value="something" />
and not the label, that you have to add, just like text or with a <%= label_tag 'whatever' %>
.
Upvotes: 1
Reputation: 3427
one way to do is
<%= check_box_tag "Monday", 'yes', id:"monday" %> Monday
or u can do this also
<%= check_box_tag "Monday", "yes" %>
<%= label_tag "Monday" %>
Upvotes: 0
Reputation: 645
try the below code
<%= check_box :monday, {:class => "anyclass", :style => "anystyle"}, "monday" %>
Upvotes: 0