Class: SdrViewComponents::Forms::InvalidFeedbackComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- SdrViewComponents::Forms::InvalidFeedbackComponent
- Defined in:
- app/components/sdr_view_components/forms/invalid_feedback_component.rb
Overview
Component for rendering invalid feedback for a form field.
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
-
#initialize(field_name:, form:, classes: [], **args) ⇒ InvalidFeedbackComponent
constructor
A new instance of InvalidFeedbackComponent.
- #render? ⇒ Boolean
Methods inherited from BaseComponent
#args_for, #merge_actions, #merge_classes
Constructor Details
#initialize(field_name:, form:, classes: [], **args) ⇒ InvalidFeedbackComponent
Returns a new instance of InvalidFeedbackComponent.
7 8 9 10 11 12 13 |
# File 'app/components/sdr_view_components/forms/invalid_feedback_component.rb', line 7 def initialize(field_name:, form:, classes: [], **args) @field_name = field_name @form = form @classes = classes @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/invalid_feedback_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/invalid_feedback_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/invalid_feedback_component.rb', line 15 def form @form end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 |
# File 'app/components/sdr_view_components/forms/invalid_feedback_component.rb', line 17 def call tag.div(class: classes, id:, **args) do errors.join(', ') end end |
#render? ⇒ Boolean
23 24 25 |
# File 'app/components/sdr_view_components/forms/invalid_feedback_component.rb', line 23 def render? field_name.present? && errors.present? end |