Class: SdrViewComponents::Forms::HasOneComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- SdrViewComponents::Forms::HasOneComponent
- Defined in:
- app/components/sdr_view_components/forms/has_one_component.rb
Overview
Encapsulates a has_one (non-repeatable) form.
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#field_name ⇒ Object
readonly
Returns the value of attribute field_name.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#form_component ⇒ Object
readonly
Returns the value of attribute form_component.
Instance Method Summary collapse
-
#fieldset_args ⇒ Object
Returns a hash of arguments for the fieldset component.
-
#form_component_args ⇒ Object
Returns a hash of arguments for the form component.
-
#initialize(form:, field_name:, form_component:, **args) ⇒ HasOneComponent
constructor
A new instance of HasOneComponent.
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
#args ⇒ Object (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_name ⇒ Object (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 |
#form ⇒ Object (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_component ⇒ Object (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_args ⇒ Object
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_args ⇒ Object
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 |