<% # formstrap/media # # ==== Required parameters # * +attribute+ - Name of the attribute of the form model # * +form+ - Form object # # ==== Optional parameters # * +destroy+ - Adds delete buttons to the preview thumbnails # * +hint+ - Informative text to assist with data input. HTML markup is allowed # * +label+ - Text to display inside label tag. Defaults to the attribute name. Set to false if you don"t want to show a label # * +min+ - Limit the selection to a minimum amount of items # * +max+ - Limit the selection to a maximum amount of items # * +sort+ - Allow sorting by dragging items. `active_storage_attachments` must have a position column # * +wrapper+ - Hash with all options for the surrounding html tag # * +width+ - Width of the thumbnail # * +height+ - Height of the thumbnail # # ==== References # https://headmin.dev/docs/forms/media # # ==== Examples # Basic version # <%= form_with do |form| %#> # <%= render "formstrap/media", form: form, attribute: :file %#> # <% end %#> media = Formstrap::MediaView.new(local_assigns) %> <%= render "formstrap/wrapper", media.wrapper_options do %> <%= render "formstrap/label", media.label_options if media.prepend_label? %>
<%= render "formstrap/media/validation", media.custom_validation_options %> <%= form.fields_for(media.nested_attribute, media.association_object) do |ff| %> <%= render "formstrap/media/item", media.item_options.merge(form: ff, url: formstrap_media_url(name: media.name, ids: media.blob_ids, min: media.min, max: media.max, mimetype: media.accept)) %> <% end %>
" data-media-target="placeholder"> <%= render "formstrap/shared/thumbnail", media.thumbnail_options %>
<% association_object = ActiveStorage::Attachment.new %> <%= render "formstrap/validation", media.validation_options if media.validate? %> <%= render "formstrap/hint", media.hint_options if media.hint? %> <%= render "formstrap/label", media.label_options if media.append_label? %> <% end %>