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:, form_group:, include_hidden:, **kwargs, &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
# 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:, form_group:, include_hidden:, **kwargs, &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
  @form_group      = form_group
  @include_hidden  = include_hidden
  @bold_labels     = (bold_labels.nil? && auto_bold_labels?) || bold_labels
  @html_attributes = kwargs
end

Instance Method Details

#htmlObject



27
28
29
30
31
32
33
# File 'lib/govuk_design_system_formbuilder/elements/radios/collection.rb', line 27

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