Class: Practical::Views::Form::FieldErrorsComponent
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- Practical::Views::Form::FieldErrorsComponent
- Defined in:
- app/components/practical/views/form/field_errors_component.rb
Instance Attribute Summary collapse
-
#f ⇒ Object
readonly
Returns the value of attribute f.
-
#object_method ⇒ Object
readonly
Returns the value of attribute object_method.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(f:, object_method:, options:) ⇒ FieldErrorsComponent
constructor
A new instance of FieldErrorsComponent.
Constructor Details
#initialize(f:, object_method:, options:) ⇒ FieldErrorsComponent
Returns a new instance of FieldErrorsComponent.
6 7 8 9 10 |
# File 'app/components/practical/views/form/field_errors_component.rb', line 6 def initialize(f:, object_method:, options:) @f = f @object_method = object_method @options = end |
Instance Attribute Details
#f ⇒ Object (readonly)
Returns the value of attribute f.
4 5 6 |
# File 'app/components/practical/views/form/field_errors_component.rb', line 4 def f @f end |
#object_method ⇒ Object (readonly)
Returns the value of attribute object_method.
4 5 6 |
# File 'app/components/practical/views/form/field_errors_component.rb', line 4 def object_method @object_method end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'app/components/practical/views/form/field_errors_component.rb', line 4 def @options end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/components/practical/views/form/field_errors_component.rb', line 12 def call id = f.field_errors_id(object_method) classes = ["error-section", "wa-callout", "wa-danger"] errors = f.errors_for(object_method) if errors.blank? classes << ["no-server-errors"] errors = [] end = mix({id: id, class: classes}, ) return label(object_method, nil, ) { render Practical::Views::Form::ErrorListComponent.new(errors: errors) } end |