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

0

4 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" %> 
1

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" %> 

You need to use a label:

<%= form_tag your_path do %> <%= label "Day" %> <%= check_box "Monday", "yes" %> <% end %> 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.