Class: GOVUKDesignSystemFormBuilder::Elements::Select

Inherits:
Base
  • Object
show all
Includes:
Traits::ContentBeforeAndAfter, 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::ContentBeforeAndAfter

#after_input_content, #before_input_content

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:, before_input:, after_input:, **kwargs, &block) ⇒ Select



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

def initialize(builder, object_name, attribute_name, choices, options:, form_group:, label:, hint:, caption:, before_input:, after_input:, **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
  @before_input    = before_input
  @after_input     = after_input
end

Instance Method Details

#htmlObject



28
29
30
31
32
# File 'lib/govuk_design_system_formbuilder/elements/select.rb', line 28

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