Method: CCS::Components::GovUK::Field::Input::Select#render

Defined in:
lib/ccs/components/govuk/field/input/select.rb

#renderActiveSupport::SafeBuffer

Generates the HTML for the GOV.UK Select component

Returns:

  • (ActiveSupport::SafeBuffer)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ccs/components/govuk/field/input/select.rb', line 52

def render
  super do
    if options[:form]
      options[:form].select(
        attribute,
        items,
        {},
        **options[:attributes]
      )
    else
      context.select_tag(
        attribute,
        context.options_for_select(
          items,
          selected
        ),
        **options[:attributes]
      )
    end
  end
end