Class: SdrViewComponents::Forms::HasOneComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/sdr_view_components/forms/has_one_component.rb

Overview

Encapsulates a has_one (non-repeatable) form.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseComponent

#args_for, #mark_label_required, #merge_actions, #merge_classes

Constructor Details

#initialize(form:, field_name:, form_component:, **args) ⇒ HasOneComponent

Returns a new instance of HasOneComponent.



7
8
9
10
11
12
13
# File 'app/components/sdr_view_components/forms/has_one_component.rb', line 7

def initialize(form:, field_name:, form_component:, **args)
  @form = form
  @field_name = field_name
  @form_component = form_component
  @args = args
  super()
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



15
16
17
# File 'app/components/sdr_view_components/forms/has_one_component.rb', line 15

def args
  @args
end

#field_nameObject (readonly)

Returns the value of attribute field_name.



15
16
17
# File 'app/components/sdr_view_components/forms/has_one_component.rb', line 15

def field_name
  @field_name
end

#formObject (readonly)

Returns the value of attribute form.



15
16
17
# File 'app/components/sdr_view_components/forms/has_one_component.rb', line 15

def form
  @form
end

#form_componentObject (readonly)

Returns the value of attribute form_component.



15
16
17
# File 'app/components/sdr_view_components/forms/has_one_component.rb', line 15

def form_component
  @form_component
end

Instance Method Details

#fieldset_argsObject

Returns a hash of arguments for the fieldset component. Includes argument prefixed with 'fieldset_'.



19
20
21
# File 'app/components/sdr_view_components/forms/has_one_component.rb', line 19

def fieldset_args
  args_for(args:, prefix: 'fieldset_')
end

#form_component_argsObject

Returns a hash of arguments for the form component. Includes argument prefixed with 'form_'.



25
26
27
# File 'app/components/sdr_view_components/forms/has_one_component.rb', line 25

def form_component_args
  args_for(args:, prefix: 'form_')
end