4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'app/inputs/order_form_builder.rb', line 4
def tree_collection_select(method, collection, option_key_method, option_value_method, options = {}, html_options = {})
choices = collection.each_with_object([]) do |record, items|
items << [record.send(option_value_method), record.send(option_key_method), { class: [record.root? ? 'root' : 'child'] }]
next unless record.root? && record.parsed_children
record.parsed_children.each do |child|
items << [child.send(option_value_method), child.send(option_key_method), { class: ['child'] }]
end
end
@template.select(@object_name, method, choices, objectify_options(options), @default_options.merge(html_options))
end
|