Class: GOVUKDesignSystemFormBuilder::Elements::CheckBoxes::Collection

Inherits:
Base
  • Object
show all
Includes:
Traits::Error, Traits::Hint, Traits::Supplemental
Defined in:
lib/govuk_design_system_formbuilder/elements/check_boxes/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:, legend:, caption:, small:, form_group:, include_hidden:, hint_method: nil, **kwargs, &block) ⇒ Collection

Returns a new instance of Collection.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/govuk_design_system_formbuilder/elements/check_boxes/collection.rb', line 9

def initialize(builder, object_name, attribute_name, collection, value_method:, text_method:, hint:, legend:, caption:, small:, form_group:, include_hidden:, hint_method: nil, **kwargs, &block)
  super(builder, object_name, attribute_name, &block)

  @collection      = collection
  @value_method    = value_method
  @text_method     = text_method
  @hint_method     = hint_method
  @small           = small
  @legend          = legend
  @caption         = caption
  @hint            = hint
  @form_group      = form_group
  @include_hidden  = include_hidden
  @html_attributes = kwargs
end

Instance Method Details

#htmlObject



25
26
27
28
29
30
31
# File 'lib/govuk_design_system_formbuilder/elements/check_boxes/collection.rb', line 25

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