Class: GOVUKDesignSystemFormBuilder::Containers::Fieldset

Inherits:
Base
  • Object
show all
Includes:
Traits::Localisation
Defined in:
lib/govuk_design_system_formbuilder/containers/fieldset.rb

Constant Summary collapse

LEGEND_SIZES =
%w(xl l m s).freeze

Instance Method Summary collapse

Constructor Details

#initialize(builder, object_name = nil, attribute_name = nil, legend: {}, described_by: nil) ⇒ Fieldset

Returns a new instance of Fieldset.


8
9
10
11
12
13
14
# File 'lib/govuk_design_system_formbuilder/containers/fieldset.rb', line 8

def initialize(builder, object_name = nil, attribute_name = nil, legend: {}, described_by: nil)
  super(builder, object_name, attribute_name)

  @legend         = legend_defaults.merge(legend)
  @described_by   = described_by(described_by)
  @attribute_name = attribute_name
end

Instance Method Details

#htmlObject


16
17
18
19
20
# File 'lib/govuk_design_system_formbuilder/containers/fieldset.rb', line 16

def html
  ('fieldset', class: fieldset_classes, aria: { describedby: @described_by }) do
    safe_join([build_legend, yield])
  end
end