Checkbox
Check it out! Ha haaa.. ha.
Includes a Ruby component and corresponding Rails helper
RubyForm use
To use in forms, it's easiest to use the Form Builder.
f.checkbox
tries to match Rails' own API.
For extra convenience use the f.field
method.
<%= nk_form_with model: @session do |f| %>
<%= f.field :remember_me,
as: :checkbox,
label: "Remember me",
description: "At least for a little bit" %>
<% end %>
With a label
To add a label, use the label:
argument.
<%= nk_checkbox label: "Accept your fate" %>
Checkbox group
Display multiple related checkboxes in a group under the same title.
<%= nk_checkbox_group do |g| %>
<%= g.title "Choose your poison" %>
<%= g.item value: :coke, label: "Coke", checked: true %>
<%= g.item value: :zero, label: "Coke Zero" %>
<% end %>
Usage
NB: Using through FormBuilder#field
is recommended. See Field docs.
| ||
---|---|---|
Property | Default | Description |
compat_object_name | nil | API compatibility Relevant object |
compat_method | nil | API compatibility Object attribute |
compat_options | {} | API compatibility Options for checkbox |
compat_checked_value | "1" | API compatibility Value when checked |
compat_unchecked_value | "0" | API compatibility Value when unchecked |
label | nil | Text label for checkbox |
**attrs | HTML attributes for <input> element |