66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'app/helpers/searchify/searchify_helper.rb', line 66
def searchify(field, *args)
options = args.
model_name = options.delete(:model_name) || (field)
field_name = options.delete(:field_name) || (field)
collection = options.delete(:collection) || (model_name)
search_url = options.delete(:search_url) || (collection, options.delete(:scopes), options.delete(:search_strategy))
options[:class] = [:searchify].push(options[:class]).flatten.compact
options[:data] = {:'search-url' => search_url}.merge(options[:data] || {})
options[:id] ||= "#{object_name.gsub(/\[/, '_').gsub(/\]/, '')}_#{field_name}"
label_method = options.delete(:label_method) || Searchify::Config.label_method
html_value = object.respond_to?(model_name) ? object.send(model_name).try(label_method) : ""
hidden_field(field_name, :id => "#{options[:id]}_hidden") + @template.text_field_tag(:searchify, html_value, options)
end
|