Method: CCS::Components::GovUK::Field::Input::Select#initialize
- Defined in:
- lib/ccs/components/govuk/field/input/select.rb
#initialize(attribute:, items:, selected: nil) ⇒ Select
Returns a new instance of Select.
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ccs/components/govuk/field/input/select.rb', line 35 def initialize(attribute:, items:, selected: nil, **) super(attribute: attribute, **) @items = items.map do |item| [ item[:text] || item[:value], item[:value].nil? ? item[:text] : item[:value], item[:attributes] || {} ] end @selected = @options[:model] ? @options[:model].send(attribute) : selected end |