Class: Pajamas::CheckboxComponent

Inherits:
Component
  • Object
show all
Includes:
Pajamas::Concerns::CheckboxRadioLabelWithHelpText, Pajamas::Concerns::CheckboxRadioOptions
Defined in:
app/components/pajamas/checkbox_component.rb

Instance Method Summary collapse

Methods included from Pajamas::Concerns::CheckboxRadioOptions

#formatted_input_options

Methods included from Pajamas::Concerns::CheckboxRadioLabelWithHelpText

#render_label_tag_with_help_text, #render_label_with_help_text

Constructor Details

#initialize(form:, method:, label: nil, help_text: nil, label_options: {}, checkbox_options: {}, checked_value: '1', unchecked_value: '0') ⇒ CheckboxComponent

Returns a new instance of CheckboxComponent.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/components/pajamas/checkbox_component.rb', line 16

def initialize(
  form:,
  method:,
  label: nil,
  help_text: nil,
  label_options: {},
  checkbox_options: {},
  checked_value: '1',
  unchecked_value: '0'
)
  @form = form
  @method = method
  @label_argument = label
  @help_text_argument = help_text
  @label_options = label_options
  @input_options = checkbox_options
  @checked_value = checked_value
  @unchecked_value = unchecked_value
  @value = checked_value if checkbox_options[:multiple]
end