Class: Form::Select

Inherits:
BaseTag
  • Object
show all
Defined in:
app/views/form/select.rb

Instance Method Summary collapse

Instance Method Details

#view_templateObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/views/form/select.rb', line 12

def view_template
  input(type: :hidden, name:, value: "", autocomplete: "off") if include_hidden?
  select(id:, name:, class: classes, **html_options) do
    if prompt
      option(value: "") { prompt }
    elsif include_blank?
      blank_text = include_blank.is_a?(String) ? include_blank : nil
      option(value: "") { blank_text }
    end
    choices.each do |choice|
      option(value: value_for(choice), selected: selected_for?(choice), disabled: disabled_for?(choice)) { text_for(choice) }
    end
  end
end