Class: Katalyst::GOVUK::FormBuilder::Elements::Combobox

Inherits:
GOVUKDesignSystemFormBuilder::Base
  • Object
show all
Includes:
GOVUKDesignSystemFormBuilder::Traits::ContentBeforeAndAfter, GOVUKDesignSystemFormBuilder::Traits::Error, GOVUKDesignSystemFormBuilder::Traits::HTMLAttributes, GOVUKDesignSystemFormBuilder::Traits::Hint, GOVUKDesignSystemFormBuilder::Traits::Label
Defined in:
lib/katalyst/govuk/form_builder/elements/combobox.rb

Instance Method Summary collapse

Constructor Details

#initialize(builder, object_name, attribute_name, options_or_src, options:, form_group:, label:, hint:, caption:, before_input:, after_input:, **kwargs, &block) ⇒ Combobox

Returns a new instance of Combobox.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/katalyst/govuk/form_builder/elements/combobox.rb', line 16

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

  @form_group      = form_group
  @hint            = hint
  @label           = label
  @caption         = caption
  @options_or_src  = options_or_src
  @options         = options
  @html_attributes = kwargs
  @before_input    = before_input
  @after_input     = after_input
end

Instance Method Details

#htmlObject



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/katalyst/govuk/form_builder/elements/combobox.rb', line 45

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