Module: FilepickerRails::FormHelper

Includes:
Tag
Defined in:
app/helpers/filepicker_rails/form_helper.rb

Constant Summary

Constants included from Tag

Tag::FILEPICKER_OPTIONS_TO_CAMELIZE, Tag::FILEPICKER_OPTIONS_TO_DASHERIZE

Instance Method Summary collapse

Instance Method Details

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

Creates a filepicker field, accepts optional ‘options` hash for configuration.

#### Options

  • ‘:button_text` - The text of the upload button.

  • ‘:button_class` - The class of the upload button.

  • ‘:extensions` - The extensions of file types you want to support for this upload. Ex: `.png,.jpg`.

  • ‘:mimetypes` - The file types you want to support for this upload. Ex: `image/png,text/*`.

  • ‘:container` - Where to show the file picker dialog can be `modal`, `window` or the id of an iframe on the page.

  • ‘:multiple` - (true or false) Whether or not multiple uploads can be saved at once.

  • ‘:services` - What services your users can upload to. Ex: `BOX, COMPUTER, FACEBOOK`.

  • ‘:store_path` - The path to store the file at within the specified file store.

  • ‘:store_location` - The file is not copied by default. It remains in the original location. If you wish you have the file copied onto your own storage, you can specify where we should put the copy. The only value at the moment is `S3`.

  • ‘:store_container` - The bucket or container in your specified `store_location`. Defaults to the container specified in the developer portal. Does not apply to Dropbox storage.

  • ‘:store_access` - Should the underlying file be publicly available on its S3 link. Options are `public` and `private`, defaults to ’private’.

  • ‘:dragdrop` - (`true` or `false`) Whether or not to allow drag-and-drop uploads.

  • ‘:drag_text` - The text of the dragdrop pane.

  • ‘:drag_class` - The class of the dragdrop pane.

  • ‘:onchange` - The onchange event.

  • ‘:max_size` - The maximum file size allowed, in bytes.

  • ‘:max_files` - The maximum number of files.

  • ‘:open_to` - Open the picker to the given service. Ex: `COMPUTER`.

  • ‘:class` - Add a class to the input.

  • ‘:value` - Define the value of the input

#### Examples

filepicker_field(:filepicker_url)
# => <input data-fp-apikey="..." id="user_filepicker_url" name="user[filepicker_url]" type="filepicker" />

This is mixed on form for to be used like.

<%= form_for @user do |f| %>
  <%= f.filepicker_field :filepicker_url %>
  <%= f.submit %>
<% end %>


43
44
45
46
47
48
49
50
51
# File 'app/helpers/filepicker_rails/form_helper.rb', line 43

def filepicker_field(method, options = {})
  define_input_options(options)
  @method = method
  if rails_greater_than_4?
    rails_greater_than_4_input
  else
    rails_input
  end
end