Sha256: a0b2fde702c03c268bd0d707a11f4ad005760b132c4e648cd041ef98bdc5a945

Contents?: true

Size: 568 Bytes

Versions: 33

Compression:

Stored size: 568 Bytes

Contents

module GOVUKDesignSystemFormBuilder
  module Elements
    class ErrorMessage < Base
      using PrefixableArray

      include Traits::Error

      def html
        return unless has_errors?

        tag.p(class: %(#{brand}-error-message), id: error_id) do
          safe_join([hidden_prefix, message])
        end
      end

    private

      def hidden_prefix
        tag.span('Error: ', class: %(#{brand}-visually-hidden))
      end

      def message
        set_message_safety(@builder.object.errors.messages[@attribute_name]&.first)
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
govuk_design_system_formbuilder-5.8.0 lib/govuk_design_system_formbuilder/elements/error_message.rb
govuk_design_system_formbuilder-5.7.1 lib/govuk_design_system_formbuilder/elements/error_message.rb
govuk_design_system_formbuilder-5.7.0 lib/govuk_design_system_formbuilder/elements/error_message.rb
govuk_design_system_formbuilder-5.6.0 lib/govuk_design_system_formbuilder/elements/error_message.rb
govuk_design_system_formbuilder-5.5.0 lib/govuk_design_system_formbuilder/elements/error_message.rb
govuk_design_system_formbuilder-5.4.1 lib/govuk_design_system_formbuilder/elements/error_message.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/govuk_design_system_formbuilder-5.4.0/lib/govuk_design_system_formbuilder/elements/error_message.rb
govuk_design_system_formbuilder-5.3.3 lib/govuk_design_system_formbuilder/elements/error_message.rb
govuk_design_system_formbuilder-5.3.2 lib/govuk_design_system_formbuilder/elements/error_message.rb
govuk_design_system_formbuilder-5.3.1 lib/govuk_design_system_formbuilder/elements/error_message.rb
govuk_design_system_formbuilder-5.3.0 lib/govuk_design_system_formbuilder/elements/error_message.rb
govuk_design_system_formbuilder-5.2.0 lib/govuk_design_system_formbuilder/elements/error_message.rb
govuk_design_system_formbuilder-5.1.0 lib/govuk_design_system_formbuilder/elements/error_message.rb
govuk_design_system_formbuilder-5.1.0b1 lib/govuk_design_system_formbuilder/elements/error_message.rb
govuk_design_system_formbuilder-5.0.0 lib/govuk_design_system_formbuilder/elements/error_message.rb
govuk_design_system_formbuilder-5.0.0b1 lib/govuk_design_system_formbuilder/elements/error_message.rb
govuk_design_system_formbuilder-4.1.1 lib/govuk_design_system_formbuilder/elements/error_message.rb
govuk_design_system_formbuilder-4.1.0 lib/govuk_design_system_formbuilder/elements/error_message.rb
govuk_design_system_formbuilder-4.0.0 lib/govuk_design_system_formbuilder/elements/error_message.rb
govuk_design_system_formbuilder-4.0.0rc1 lib/govuk_design_system_formbuilder/elements/error_message.rb