Class: SdrViewComponents::Forms::ToggleComponent

Inherits:
FieldComponent show all
Defined in:
app/components/sdr_view_components/forms/toggle_component.rb

Overview

Component for a toggle-like radio button group field

Instance Attribute Summary collapse

Attributes inherited from FieldComponent

#args, #variant

Instance Method Summary collapse

Methods inherited from FieldComponent

#container_args, #container_classes, #error_args, #help_text_args, #help_text_below?, #input_args, #input_component, #label_args, #label_field_name

Methods inherited from BaseComponent

#args_for, #merge_actions, #merge_classes

Constructor Details

#initialize(form:, field_name:, **args) ⇒ ToggleComponent

Returns a new instance of ToggleComponent.



14
15
16
17
18
19
# File 'app/components/sdr_view_components/forms/toggle_component.rb', line 14

def initialize(form:, field_name:, **args)
  @form = form
  @field_name = field_name
  args[:label_classes] = merge_classes('d-block', args[:label_classes])
  super
end

Instance Attribute Details

#field_nameObject (readonly)

Returns the value of attribute field_name.



21
22
23
# File 'app/components/sdr_view_components/forms/toggle_component.rb', line 21

def field_name
  @field_name
end

#formObject (readonly)

Returns the value of attribute form.



21
22
23
# File 'app/components/sdr_view_components/forms/toggle_component.rb', line 21

def form
  @form
end