Class: GroupedCollectionSelectInput

Inherits:
SimpleForm::Inputs::GroupedCollectionSelectInput
  • Object
show all
Defined in:
app/inputs/grouped_collection_select_input.rb

Overview

A saner alternative to SimpleForm’s :grouped_select input type makandracards.com/makandra/25205-a-saner-alternative-to-simpleform-s-grouped_select-input-type

Instance Method Summary collapse

Instance Method Details

#input(wrapper_options = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/inputs/grouped_collection_select_input.rb', line 5

def input(wrapper_options = nil)
  group_by = options.delete(:group_by)

  if group_by
    grouped_collection = options[:collection].group_by(&group_by)

    options[:collection] = grouped_collection
    options[:group_method] = :last
    options[:group_label_method] = :first
  end

  super
end