Class: GOVUKDesignSystemFormBuilder::Containers::Fieldset

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

Instance Method Summary collapse

Methods included from Traits::HTMLAttributes

#attributes

Methods inherited from Base

#field_id, #to_s

Constructor Details

#initialize(builder, object_name = nil, attribute_name = nil, legend: {}, caption: {}, described_by: nil, **kwargs, &block) ⇒ Fieldset

Returns a new instance of Fieldset.



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

def initialize(builder, object_name = nil, attribute_name = nil, legend: {}, caption: {}, described_by: nil, **kwargs, &block)
  super(builder, object_name, attribute_name, &block)

  @legend          = legend
  @caption         = caption
  @described_by    = combine_references(described_by)
  @attribute_name  = attribute_name
  @html_attributes = kwargs
end

Instance Method Details

#htmlObject



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

def html
  tag.fieldset(**attributes(@html_attributes)) do
    safe_join([legend_element, (@block_content || yield)])
  end
end