Sha256: f25cacfcab85df6f10510da5134c5f2e5bf32742f1849e4526f4ff8feb8a53e3
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
module SimpleForm module Components module Remote def remote(wrapper_options = nil) @remote ||= begin remote_options = options[:remote].is_a?(Hash) ? options[:remote] : {} remote_options[:path] ||= template.polymorphic_path([:admin, reflection.klass]) unless remote_options[:path].match(/\.json$/i) if remote_options[:path].match(/\?/) remote_options[:path] = remote_options[:path].sub(/\?/, '.json?') else remote_options[:path] << '.json' end end input_html_options[:data] ||= {} input_html_options[:data][:remote_path] = remote_options[:path] input_html_options[:data][:remote_scope] = remote_options[:scope] || 'fuzzy_search' options[:wrapper_html] ||= {} options[:wrapper_html][:class] = "#{options[:wrapper_html][:class]} remote" options[:collection] = Array(object.send(reflection.name)).collect { |a| [a.to_label, a.id, data: { select2_response: a.to_select2_response, select2_selection: a.to_select2_selection }] } end nil end def remote? options[:remote].present? end end end end SimpleForm::Inputs::Base.send(:include, SimpleForm::Components::Remote)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
forest_cms-0.98.1 | config/initializers/simple_form/remote.rb |