Class: UI::FieldErrorComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- UI::FieldErrorComponent
- Includes:
- FieldErrorBehavior
- Defined in:
- app/view_components/ui/field_error_component.rb
Overview
FieldErrorComponent - ViewComponent implementation
Error message display for form fields with accessibility support. Uses FieldErrorBehavior concern for shared styling logic.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(errors: nil, classes: "", **attributes) ⇒ FieldErrorComponent
constructor
A new instance of FieldErrorComponent.
Methods included from FieldErrorBehavior
#error_message, #field_error_classes, #field_error_html_attributes, #has_errors?, #multiple_errors?, #single_error?
Constructor Details
#initialize(errors: nil, classes: "", **attributes) ⇒ FieldErrorComponent
Returns a new instance of FieldErrorComponent.
24 25 26 27 28 |
# File 'app/view_components/ui/field_error_component.rb', line 24 def initialize(errors: nil, classes: "", **attributes) @errors = errors @classes = classes @attributes = attributes end |
Instance Method Details
#call ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'app/view_components/ui/field_error_component.rb', line 30 def call return unless has_errors? || content? if has_errors? render_errors else render_content end end |