Sha256: bfcdc0eab987fb1d24d1b2a70a154f4b4ae07f7055cdc8a488d0802fe9713fa3

Contents?: true

Size: 673 Bytes

Versions: 7

Compression:

Stored size: 673 Bytes

Contents

# make attachment_field behave like a normal input type so we get nice wrapper and labels
# <%= f.input :cover_image, as: :attachment, direct: true, presigned: true %>
module SimpleForm
  module Inputs
    class AttachmentInput < Base
      def input(wrapper_options = nil)
        refile_options = [:presigned, :direct, :multiple]
        merged_input_options = merge_wrapper_options(input_options.slice(*refile_options).merge(input_html_options), wrapper_options)
        @builder.attachment_field(attribute_name, merged_input_options)
      end
    end
  end
end

SimpleForm::FormBuilder.class_eval do
  map_type :attachment, to: SimpleForm::Inputs::AttachmentInput
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
leifcr-refile-0.7.3 lib/refile/simple_form.rb
leifcr-refile-0.7.1 lib/refile/simple_form.rb
leifcr-refile-0.7.0 lib/refile/simple_form.rb
leifcr-refile-0.6.3 lib/refile/simple_form.rb
refile-0.6.2 lib/refile/simple_form.rb
refile-0.6.1 lib/refile/simple_form.rb
refile-0.6.0 lib/refile/simple_form.rb