Class: SdrViewComponents::Forms::BasicComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- SdrViewComponents::Forms::BasicComponent
- Defined in:
- app/components/sdr_view_components/forms/basic_component.rb
Overview
Base component for basic components.
Direct Known Subclasses
BasicCheckboxComponent, BasicFileComponent, BasicRadioButtonComponent, BasicSelectFieldComponent, BasicTextAreaComponent, BasicTextFieldComponent
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.
Instance Method Summary collapse
- #call ⇒ Object
-
#classes ⇒ Object
Subclasses can override this to provide default classes, e.g., form-check-input.
-
#initialize(form:, field_name:, classes: [], **args) ⇒ BasicComponent
constructor
Subclasses may override this if additional args, e.g., value, are needed.
Methods inherited from BaseComponent
#args_for, #merge_actions, #merge_classes
Constructor Details
#initialize(form:, field_name:, classes: [], **args) ⇒ BasicComponent
Subclasses may override this if additional args, e.g., value, are needed.
8 9 10 11 12 13 14 |
# File 'app/components/sdr_view_components/forms/basic_component.rb', line 8 def initialize(form:, field_name:, classes: [], **args) @form = form @field_name = field_name @args = args @classes = classes super() end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
16 17 18 |
# File 'app/components/sdr_view_components/forms/basic_component.rb', line 16 def args @args end |
#field_name ⇒ Object (readonly)
Returns the value of attribute field_name.
16 17 18 |
# File 'app/components/sdr_view_components/forms/basic_component.rb', line 16 def field_name @field_name end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
16 17 18 |
# File 'app/components/sdr_view_components/forms/basic_component.rb', line 16 def form @form end |
Instance Method Details
#call ⇒ Object
18 19 20 |
# File 'app/components/sdr_view_components/forms/basic_component.rb', line 18 def call raise NotImplementedError, 'Subclasses must implement the call method' end |
#classes ⇒ Object
Subclasses can override this to provide default classes, e.g., form-check-input
23 24 25 |
# File 'app/components/sdr_view_components/forms/basic_component.rb', line 23 def classes merge_classes(@classes) end |