Class: GOVUKDesignSystemFormBuilder::Containers::RadioButtonsFieldset

Inherits:
Base
  • Object
show all
Includes:
Traits::Error, Traits::Hint
Defined in:
lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb

Instance Method Summary collapse

Methods included from Traits::Error

#error_id

Methods included from Traits::Hint

#hint_id

Constructor Details

#initialize(builder, object_name, attribute_name, hint_text:, legend:, inline:, small:, classes:, &block) ⇒ RadioButtonsFieldset


7
8
9
10
11
12
13
14
15
16
# File 'lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb', line 7

def initialize(builder, object_name, attribute_name, hint_text:, legend:, inline:, small:, classes:, &block)
  super(builder, object_name, attribute_name)

  @inline        = inline
  @small         = small
  @legend        = legend
  @hint_text     = hint_text
  @classes       = classes
  @block_content = capture { block.call }
end

Instance Method Details

#htmlObject


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb', line 18

def html
  Containers::FormGroup.new(@builder, @object_name, @attribute_name).html do
    Containers::Fieldset.new(@builder, @object_name, @attribute_name, legend: @legend, described_by: [error_element.error_id, hint_element.hint_id]).html do
      safe_join(
        [
          hint_element.html,
          error_element.html,
          Containers::Radios.new(@builder, inline: @inline, small: @small, classes: @classes).html do
            @block_content
          end
        ]
      )
    end
  end
end