Class: GOVUKDesignSystemFormBuilder::Elements::ErrorSummary

Inherits:
Base
  • Object
show all
Includes:
Traits::Error, Traits::HTMLAttributes
Defined in:
lib/govuk_design_system_formbuilder/elements/error_summary.rb

Instance Method Summary collapse

Methods included from Traits::HTMLAttributes

#attributes

Methods included from Traits::Error

#error_id

Methods inherited from Base

#to_s

Constructor Details

#initialize(builder, object_name, title, link_base_errors_to:, order:, presenter:, **kwargs, &block) ⇒ ErrorSummary

Returns a new instance of ErrorSummary.


7
8
9
10
11
12
13
14
15
# File 'lib/govuk_design_system_formbuilder/elements/error_summary.rb', line 7

def initialize(builder, object_name, title, link_base_errors_to:, order:, presenter:, **kwargs, &block)
  super(builder, object_name, nil, &block)

  @title               = title
  @link_base_errors_to = link_base_errors_to
  @html_attributes     = kwargs
  @order               = order
  @presenter           = presenter
end

Instance Method Details

#htmlObject


17
18
19
20
21
22
23
# File 'lib/govuk_design_system_formbuilder/elements/error_summary.rb', line 17

def html
  return unless object_has_errors?

  tag.div(**attributes(@html_attributes)) do
    safe_join([title, summary])
  end
end