Skip to content

Checkbox Tag

Stanislas Michalak edited this page Dec 29, 2017 · 4 revisions

Tags provide a convenient way to build an HTML element with type="checkbox":

<%= f.CheckboxTag({name: "IsPublic"}) %>

That produces:

<label>
  <input class="" id="talk-IsPublic" name="IsPublic" type="checkbox" value="true" checked="">
  IsPublic
</label>

You can easily change the label content with

<%= f.CheckboxTag({name: "IsPublic", label: " Is the talk public?"}) %>

That produces:

<label>
  <input class="" id="post-IsPublic" name="IsPublic" type="checkbox" value="true" checked="">
   Is the Talk public?
</label>
Clone this wiki locally