Skip to content

File placement forms

Petr Marek edited this page Jan 14, 2019 · 1 revision

Multiple files

Images

Use the react_images helper (defaults shown).

def react_images(selected_placements = nil, attachmentable: 'node',
                                            type: :image_placements)
  ...
end

that is:

react_images(f.object.image_placements, attachmentable: :model_param,
                                        type: :image_placements)

i.e. having has_many :image_placements on a Namespace::Model:

react_images(f.object.image_placements, attachmentable: :namespace_model)

Documents

same as images, except react_documents is used and type defaults to :document_placements

def react_documents(selected_placements = nil, attachmentable: 'node',
                                               type: :document_placements)
  ...
end

Single file

Use the react_picker helper.

def react_picker(f, placement_key, file_type: 'Folio::Image', title: nil)
  ...
end

To single pick a cover (using Folio::FilePlacement::Cover):

react_picker(f, :cover_placement)

Custom banner placement that was added to Folio::Site, adding a title:

react_picker(f, :desktop_banner_placement, file_type: 'Folio::Image',
                                           title: Folio::Site.human_attribute_name(:desktop_banner_placement)

Custom catalogue placements (using a PDF file), adding a title:

react_picker(f, :catalogue_placement, file_type: 'Folio::Document',
                                      title: Folio::Site.human_attribute_name(:catalogue_placement))