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.
-
#multiple_errors_blurb ⇒ Object
readonly
Returns the value of attribute multiple_errors_blurb.
-
#object_method ⇒ Object
readonly
Returns the value of attribute object_method.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #errors ⇒ Object
- #finalized_options ⇒ Object
-
#initialize(f:, object_method:, multiple_errors_blurb:, options:) ⇒ FieldErrorsComponent
constructor
A new instance of FieldErrorsComponent.
Constructor Details
#initialize(f:, object_method:, multiple_errors_blurb:, options:) ⇒ FieldErrorsComponent
Returns a new instance of FieldErrorsComponent.
6 7 8 9 10 11 |
# File 'app/components/practical/views/form/field_errors_component.rb', line 6 def initialize(f:, object_method:, multiple_errors_blurb:, options:) @f = f @object_method = object_method @multiple_errors_blurb = multiple_errors_blurb @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 |
#multiple_errors_blurb ⇒ Object (readonly)
Returns the value of attribute multiple_errors_blurb.
4 5 6 |
# File 'app/components/practical/views/form/field_errors_component.rb', line 4 def multiple_errors_blurb @multiple_errors_blurb 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
#errors ⇒ Object
13 14 15 |
# File 'app/components/practical/views/form/field_errors_component.rb', line 13 def errors f.errors_for(object_method) || [] end |
#finalized_options ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/components/practical/views/form/field_errors_component.rb', line 17 def id = f.field_errors_id(object_method) classes = ["error-section"] if errors.blank? classes << ["no-server-errors"] end return mix({ id: id, class: classes, data: {'pf-error-container': true} }, ) end |