Class: AttachmentsInput

Inherits:
SimpleForm::Inputs::Base
  • Object
show all
Defined in:
app/inputs/attachments_input.rb

Instance Method Summary collapse

Instance Method Details

#input(_wrapper_options = nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'app/inputs/attachments_input.rb', line 3

def input(_wrapper_options = nil)
  definitions = Cms::Attachment.definitions_for(object.class.name, :multiple)
  if definitions.empty?
    template.render(partial: 'cms/attachments/no_attachments_defined', locals: {object: object})
  else
    names = definitions.keys.sort
    names.unshift "Select a type to upload a file" if names.size > 1
    template.render(partial: 'cms/attachments/attachment_manager', locals: {:asset_definitions => definitions, :asset_types => names, f: @builder, object: object})
  end
end