Sha256: 672c4b356f9a9be29bb2e953582b7cd9f9b3e80a85979afc5419bccc19d022ea

Contents?: true

Size: 539 Bytes

Versions: 1

Compression:

Stored size: 539 Bytes

Contents

class SearchSelectInput < Formtastic::Inputs::StringInput
  def input_html_options
    relation = @object.send(attributized_method_name)
    opts = {}
    opts[:class] = "select2-ajax"
    opts["data-fields"] = (@options[:fields] || []).to_json
    opts["data-url"] = @options[:url] || ""
    opts["data-display_name"] = @options[:display_name] || "name"
    opts["data-minimum_input_length"] = @options[:minimum_input_length] || 1
    opts["data-selected"] = relation.try(opts["data-display_name"].to_sym)
    super.merge opts
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activeadmin_addons-0.2.8 app/inputs/search_select_input.rb