Module: CCS::FrontendHelpers::GovUKFrontend::ErrorSummary
- Included in:
- CCS::FrontendHelpers::GovUKFrontend
- Defined in:
- lib/ccs/frontend_helpers/govuk_frontend/error_summary.rb
Overview
GOV.UK Error Summary
This helper is used for generating the error summary component from the GDS - Components - Error summary
Instance Method Summary collapse
-
#govuk_error_summary(title, error_summary_items = [], description = nil, **options) ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Error summary component.
-
#govuk_error_summary_with_model(model, title, description = nil, **options) ⇒ NilClass, ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Error summary component using the error messages in an ActiveModel.
Instance Method Details
#govuk_error_summary(title, error_summary_items = [], description = nil, **options) ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Error summary component
22 23 24 |
# File 'lib/ccs/frontend_helpers/govuk_frontend/error_summary.rb', line 22 def govuk_error_summary(title, error_summary_items = [], description = nil, **) Components::GovUK::ErrorSummary.new(context: self, title: title, error_summary_items: error_summary_items, description: description, **).render end |
#govuk_error_summary_with_model(model, title, description = nil, **options) ⇒ NilClass, ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Error summary component using the error messages in an ActiveModel
38 39 40 41 42 43 44 |
# File 'lib/ccs/frontend_helpers/govuk_frontend/error_summary.rb', line 38 def govuk_error_summary_with_model(model, title, description = nil, **) return if model.errors.blank? error_summary_items = model.errors.map { |error| { text: error., href: "##{error.attribute}-error" } } Components::GovUK::ErrorSummary.new(context: self, title: title, error_summary_items: error_summary_items, description: description, **).render end |