method
checkbox_tag
v8.0.0 -
Show latest stable
- Class:
ActionView::Helpers::FormTagHelper
checkbox_tag(name, *args)public
Creates a check box form input tag.
Options
-
:value - The value of the input. Defaults to "1".
-
:checked - If set to true, the checkbox will be checked by default.
-
:disabled - If set to true, the user will not be able to use this input.
-
Any other key creates standard HTML options for the tag.
Examples
checkbox_tag 'accept' # => <input id="accept" name="accept" type="checkbox" value="1" /> checkbox_tag 'rock', 'rock music' # => <input id="rock" name="rock" type="checkbox" value="rock music" /> checkbox_tag 'receive_email', 'yes', true # => <input checked="checked" id="receive_email" name="receive_email" type="checkbox" value="yes" /> checkbox_tag 'tos', 'yes', false, class: 'accept_tos' # => <input class="accept_tos" id="tos" name="tos" type="checkbox" value="yes" /> checkbox_tag 'eula', 'accepted', false, disabled: true # => <input disabled="disabled" id="eula" name="eula" type="checkbox" value="accepted" />