Class: GOVUKDesignSystemFormBuilder::Elements::Radios::FieldsetRadioButton

Inherits:
Base
  • Object
show all
Includes:
Traits::Conditional, Traits::Hint
Defined in:
lib/govuk_design_system_formbuilder/elements/radios/fieldset_radio_button.rb

Instance Method Summary collapse

Methods included from Traits::Hint

#hint_id

Constructor Details

#initialize(builder, object_name, attribute_name, value, label:, hint_text:, link_errors:, &block) ⇒ FieldsetRadioButton


8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/govuk_design_system_formbuilder/elements/radios/fieldset_radio_button.rb', line 8

def initialize(builder, object_name, attribute_name, value, label:, hint_text:, link_errors:, &block)
  super(builder, object_name, attribute_name)

  @value       = value
  @label       = label
  @hint_text   = hint_text
  @link_errors = has_errors? && link_errors

  if block_given?
    @conditional_content = wrap_conditional(block)
    @conditional_id      = conditional_id
  end
end

Instance Method Details

#htmlObject


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/govuk_design_system_formbuilder/elements/radios/fieldset_radio_button.rb', line 22

def html
  safe_join(
    [
      ('div', class: 'govuk-radios__item') do
        safe_join(
          [
            input,
            label_element.html,
            hint_element.html,
          ]
        )
      end,
      @conditional_content
    ]
  )
end