2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'app/helpers/select7/tag_helper.rb', line 2
def select7_tag(options: [], selecteds: [], suggest: {}, **attributes)
field, (value_attr, text_attr) = attributes.first
options_for_select = options.map { |item|
[item.send(value_attr), item.send(text_attr), item.send(text_attr).downcase]
}
attributes.reverse_merge!(css: {}, multiple: true, nested_attributes: nil)
attributes[:input_name] ||= "#{field.to_s.singularize}_#{value_attr}"
(@template || self).render partial: "select7/field",
locals: {
field: field,
value_attr: value_attr,
text_attr: text_attr,
selected_items: selecteds,
option_items: options_for_select,
suggest: suggest || {},
**attributes
}
end
|