Class: GOVUKDesignSystemFormBuilder::Elements::Radios::Collection

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

Instance Method Summary collapse

Methods included from Traits::Supplemental

#supplemental_id

Methods included from Traits::Hint

#hint_id

Methods included from Traits::Error

#error_id

Methods inherited from Base

#field_id, #to_s

Constructor Details

#initialize(builder, object_name, attribute_name, collection, value_method:, text_method:, hint_method:, hint:, legend:, caption:, inline:, small:, bold_labels:, classes:, form_group:, include_hidden:, &block) ⇒ Collection

Returns a new instance of Collection.


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/govuk_design_system_formbuilder/elements/radios/collection.rb', line 9

def initialize(builder, object_name, attribute_name, collection, value_method:, text_method:, hint_method:, hint:, legend:, caption:, inline:, small:, bold_labels:, classes:, form_group:, include_hidden:, &block)
  super(builder, object_name, attribute_name, &block)

  @collection     = collection
  @value_method   = value_method
  @text_method    = text_method
  @hint_method    = hint_method
  @inline         = inline
  @small          = small
  @legend         = legend
  @caption        = caption
  @hint           = hint
  @classes        = classes
  @form_group     = form_group
  @include_hidden = include_hidden
  @bold_labels    = if bold_labels.nil?
                      hint_method.present?
                    else
                      bold_labels
                    end
end

Instance Method Details

#htmlObject


31
32
33
34
35
36
37
# File 'lib/govuk_design_system_formbuilder/elements/radios/collection.rb', line 31

def html
  Containers::FormGroup.new(*bound, **@form_group).html do
    Containers::Fieldset.new(*bound, **fieldset_options).html do
      safe_join([hidden_field, supplemental_content, hint_element, error_element, radios])
    end
  end
end