Module: CCS::FrontendHelpers::GovUKFrontend::ErrorMessage
- Included in:
- CCS::FrontendHelpers::GovUKFrontend
- Defined in:
- lib/ccs/frontend_helpers/govuk_frontend/error_message.rb
Overview
GOV.UK Error Message
This helper is used for generating the error message component from the GDS - Components - Error message
Instance Method Summary collapse
-
#govuk_error_message(error_message, attribute = nil, **options) ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Error message component.
-
#govuk_error_message_with_model(model, attribute, **options) ⇒ NilClass, ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Error message component using the error messages in an ActiveModel.
Instance Method Details
#govuk_error_message(error_message, attribute = nil, **options) ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Error message component
22 23 24 |
# File 'lib/ccs/frontend_helpers/govuk_frontend/error_message.rb', line 22 def (, attribute = nil, **) Components::GovUK::ErrorMessage.new(context: self, message: , attribute: attribute, **).render end |
#govuk_error_message_with_model(model, attribute, **options) ⇒ NilClass, ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Error message component using the error messages in an ActiveModel
37 38 39 40 41 42 |
# File 'lib/ccs/frontend_helpers/govuk_frontend/error_message.rb', line 37 def (model, attribute, **) = model.errors[attribute].first return unless Components::GovUK::ErrorMessage.new(context: self, message: , attribute: attribute, **).render end |