Class: Tessa::AssetInput

Inherits:
SimpleForm::Inputs::Base
  • Object
show all
Defined in:
lib/tessa/simple_form/asset_input.rb

Instance Method Summary collapse

Instance Method Details

#input(wrapper_options = nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/tessa/simple_form/asset_input.rb', line 3

def input(wrapper_options=nil)
  merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
  field = object.class.tessa_fields[attribute_name]

  template.(
    :div,
    hidden_fields_for(object.public_send(attribute_name)),
    "class" => "tessa-upload dropzone #{"multiple" if field.multiple?}",
    "data-asset-field-prefix" => tessa_field_prefix,
    "data-dropzone-options" => (options[:dropzone] || {}).to_json,
    "data-tessa-params" => (options[:tessa_params] || {}).to_json,
  )
end