Class: GOVUKDesignSystemFormBuilder::Elements::Select

Inherits:
Base
  • Object
show all
Includes:
Traits::Error, Traits::HTMLAttributes, Traits::Hint, Traits::Label, Traits::Select
Defined in:
lib/govuk_design_system_formbuilder/elements/select.rb

Instance Method Summary collapse

Methods included from Traits::HTMLAttributes

#attributes

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, choices, options:, form_group:, label:, hint:, caption:, **kwargs, &block) ⇒ Select

Returns a new instance of Select.



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

def initialize(builder, object_name, attribute_name, choices, options:, form_group:, label:, hint:, caption:, **kwargs, &block)
  # assign the block to an variable rather than passing to super so
  # we can send it through to #select
  super(builder, object_name, attribute_name)
  @block           = block

  @form_group      = form_group
  @hint            = hint
  @label           = label
  @caption         = caption
  @choices         = choices
  @options         = options
  @html_attributes = kwargs
end

Instance Method Details

#htmlObject



25
26
27
28
29
# File 'lib/govuk_design_system_formbuilder/elements/select.rb', line 25

def html
  Containers::FormGroup.new(*bound, **@form_group).html do
    safe_join([label_element, hint_element, error_element, select])
  end
end