49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/formular/element/modules/checkable.rb', line 49
def collection
unless collection?
options[:label_options] = options[:control_label_options]
return [self]
end
base_options = collection_base_options
@collection ||= options[:collection].map do |item|
opts = base_options.dup
opts[:value] = item.send(options[:value_method])
opts[:label] = item.send(options[:label_method])
opts[:id] = if options[:id]
"#{options[:id]}_#{opts[:value]}"
else
"#{attribute_name || options[:name].gsub('[]', '')}_#{opts[:value]}"
end
self.class.(opts)
end
end
|