<% form ||= current_fields_form options ||= {} other_options ||= {} options[:multiple] ||= false if defined?(multiple) options[:multiple] = multiple ActiveSupport::Deprecation.new.warn( "The `multiple` attribute will be removed in a later version. " \ "Please pass `options: {multiple: true}` to `render` instead." ) end options[:class] = "file-upload hidden #{options[:class]}" options[:direct_upload] = true options[:data] ||= {} options[:data]['fields--file-field-target'] = "fileField" options[:data][:action] = "change->fields--file-field#handleFileSelected" persisted_files = options[:multiple] ? form.object.send(method) : [form.object.send(method)] %> <%= render 'shared/fields/field', form: form, method: method, helper: :file_field, options: options, other_options: other_options do %> <% content_for :field do %>
<%= form.file_field method, options %>
<% if form.object.send(method).attached? %>
<% persisted_files.each do |file| %>
<%= form.hidden_field "#{method}_removal".to_sym, multiple: options[:multiple], value: nil, data: {'fields--file-item-target': 'removeFileFlag'} %> <%= file.blob.filename %> <%= link_to url_for(file), class: 'button download-file mr-3', data: {'fields--file-item-target': 'downloadFileButton'} do %> <%= t('fields.download_file') %> <% end %>
<%= t('fields.remove_file') %>
<% end %>
<% end %>
<% if form.object.send(method).attached? && !options[:multiple] %> <%= t('fields.replace_file') %> <% elsif form.object.send(method).attached? && options[:multiple] %> <%= t('fields.add_another_file') %> <% elsif options[:multiple] %> <%= t('fields.upload_file') %> <% else %> <%= t('fields.upload_file') %> <% end %>
<% end %> <% end %>