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
04 Answers
Have you read this?
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' %>.
try the below code
<%= check_box :monday, {:class => "anyclass", :style => "anystyle"}, "monday" %> 1one 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" %> You need to use a label:
<%= form_tag your_path do %> <%= label "Day" %> <%= check_box "Monday", "yes" %> <% end %>