Module: Inkfilepicker::FormBuilder

Defined in:
lib/inkfilepicker/form_builder.rb

Instance Method Summary collapse

Instance Method Details

#inkfilepicker_field(method, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/inkfilepicker/form_builder.rb', line 4

def inkfilepicker_field(method, options = {})
  type = options.delete(:dragdrop) ? 'filepicker-dragdrop' : 'filepicker'

  input_options = retrive_filepicker_options(options)
  input_options['data-fp-apikey'] ||= Inkfilepicker.api_key
  input_options.merge!(secure_filepicker) unless input_options['data-fp-policy'].present?

  input_options['type'] = type

  if ::Rails.version.to_i >= 4
    ActionView::Helpers::Tags::TextField.new(@object_name, method, @template).tag('input', input_options)
  else
    ActionView::Helpers::InstanceTag.new(@object_name, method, @template).to_input_field_tag(type, input_options)
  end
end