Module: NitroKit::CheckboxHelper
- Defined in:
- app/helpers/nitro_kit/checkbox_helper.rb
Instance Method Summary collapse
-
#nk_checkbox(name, *args) ⇒ Object
Match the signature of the Rails ‘check_box` helper.
Instance Method Details
#nk_checkbox(name, *args) ⇒ Object
Match the signature of the Rails ‘check_box` helper
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/helpers/nitro_kit/checkbox_helper.rb', line 4 def nk_checkbox(name, *args) if args.length >= 4 raise ArgumentError, "wrong number of arguments (given #{args.length + 1}, expected 1..4)" end = args. value, checked = args.empty? ? ["1", false] : [*args, false] attrs = { :type => "checkbox", :name => name, :id => sanitize_to_id(name), :value => value }.update(.symbolize_keys) attrs[:checked] = "checked" if checked render(NitroKit::Checkbox.new(name, value:, **attrs)) end |