Class: IndentedCollectionSelectInput

Inherits:
SimpleForm::Inputs::CollectionSelectInput
  • Object
show all
Defined in:
app/inputs/indented_collection_select_input.rb

Instance Method Summary collapse

Instance Method Details

#inputObject



2
3
4
5
6
7
8
9
10
11
# File 'app/inputs/indented_collection_select_input.rb', line 2

def input
  label_method, value_method = detect_collection_methods
  collection.map! do |o|
    depth_method = options[:depth_method] || :depth
    spacing = (options[:spacing] || 3).to_i
    label = "\u202f" * spacing * o.send(depth_method) + o.send(label_method)
    [label, o.send(value_method)]
  end
  super
end