Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a class in check_box_tag

I search through the net and cannot find a way. So far, I have tried:

<%= check_box_tag "course[location_ids][]", location.id, class: 'checkbox-inline'%>

This will output:

input type: "checkbox" name="course[location_ids][] id="course_location_ids_" value="1" checked="checked"

For some reason, it makes a checked input.

<%= check_box_tag "course[location_ids][]", location.id, :class => 'checkbox-inline'%>

does the same as the first one

How do I add a class inside of a check_box_tag

like image 332
RailsH Avatar asked Dec 07 '25 17:12

RailsH


1 Answers

You are not using the proper format

check_box_tag(name, value = "1", checked = false, options = {})

Change the tag to the following:

<%= check_box_tag "course[location_ids][]", location.id, false, class: 'checkbox-inline'%>

Note: The 3rd option is checked value, you need to change it according to your need

Refer: check_box_tag

like image 81
Deepak Mahakale Avatar answered Dec 09 '25 12:12

Deepak Mahakale



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!