Class: Presenters::ErrorSummaryPresenter
- Inherits:
-
Object
- Object
- Presenters::ErrorSummaryPresenter
- Defined in:
- lib/govuk_design_system_formbuilder/presenters/error_summary.rb
Overview
This is the default presenter for GOVUKDesignSystemFormBuilder::Elements::ErrorSummary and is intended to be easily replaceable should you have specific requirements that aren’t met here.
The basic behaviour is to always show the first error message. In Rails, error message order is determined by the order in which the validations run, but if you need to do any other transformation or concatenation, this is the place to do it.
Instance Method Summary collapse
-
#formatted_error_messages ⇒ Array<Array(Symbol, String)>, Array<Array(Symbol, String, String)>
Converts @error_messages into an array of argument arrays that will be passed into GOVUKDesignSystemFormBuilder::Elements::ErrorSummary#list_item.
-
#initialize(error_messages) ⇒ ErrorSummaryPresenter
constructor
A new instance of ErrorSummaryPresenter.
Constructor Details
#initialize(error_messages) ⇒ ErrorSummaryPresenter
Returns a new instance of ErrorSummaryPresenter.
14 15 16 |
# File 'lib/govuk_design_system_formbuilder/presenters/error_summary.rb', line 14 def initialize() @error_messages = end |
Instance Method Details
#formatted_error_messages ⇒ Array<Array(Symbol, String)>, Array<Array(Symbol, String, String)>
Converts @error_messages into an array of argument arrays that will be passed into GOVUKDesignSystemFormBuilder::Elements::ErrorSummary#list_item.
29 30 31 |
# File 'lib/govuk_design_system_formbuilder/presenters/error_summary.rb', line 29 def @error_messages.map { |attribute, | [attribute, .first] } end |