Class: DropdownSelectInput

Inherits:
SimpleForm::Inputs::CollectionInput
  • Object
show all
Includes:
ActionView::Context, ActionView::Helpers::TagHelper
Defined in:
app/inputs/dropdown_select_input.rb

Instance Method Summary collapse

Instance Method Details

#inputObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/inputs/dropdown_select_input.rb', line 10

def input
  (:span, class: 'dropdown dropdown_select_input') do
    @builder.hidden_field(attribute_name, input_html_options) +
    (:a, class: 'dropdown_toggle_button', 'data-toggle' => 'dropdown') { selected_option[0] } +
    (:ul, class: 'dropdown_menu') {
      collection.map do |x|
        (:li, class: selected_option == x ? 'active' : nil) {
          (:a, 'data-value' => x[1]) {
            (:span, class: 'dropdown_select_input_title') { x[0] } +
            (:span, class: 'dropdown_select_input_description') { x[2] }
          }
        }
      end.join('').html_safe
    }
  end
end

#selected_optionObject



6
7
8
# File 'app/inputs/dropdown_select_input.rb', line 6

def selected_option
  collection.find { |x| x[1] == object.send(attribute_name) }
end