Class: Superform::Rails::Components::Checkboxes

Inherits:
Base
  • Object
show all
Defined in:
lib/superform/rails/components/checkboxes.rb

Instance Attribute Summary

Attributes inherited from Base

#dom, #field

Instance Method Summary collapse

Methods inherited from Base

#focus

Constructor Details

#initialize(field, options: [], **attributes) ⇒ Checkboxes

Returns a new instance of Checkboxes.



5
6
7
8
# File 'lib/superform/rails/components/checkboxes.rb', line 5

def initialize(field, options: [], **attributes)
  super(field, **attributes)
  @options = options
end

Instance Method Details

#view_template(&block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/superform/rails/components/checkboxes.rb', line 10

def view_template(&block)
  choices.each do |choice|
    if block
      yield choice
    else
      label(for: DOM.join(dom.id, choice.index)) do
        render choice.build_input
        whitespace
        plain choice.text
      end
    end
  end
end