simple_form_fancy_uploads icon indicating copy to clipboard operation
simple_form_fancy_uploads copied to clipboard

No preview nor file link when creating a new instance, fine with editing the instance, but the preview is not refreshed.

Open oasisweng opened this issue 8 years ago • 0 comments

Following the tutorial, I added both image_preview and attachment_preview to two separate input fields:

<%= f.input :resume, as: :attachment_preview, 
                       wrapper: :horizontal_file_input %>

<%= f.input :image, as: :image_preview, 
                           input_html: { :preview_version => :thumb },
                           wrapper: :horizontal_file_input
                            %>

in new page for my Staff model.

But, when I add a pdf file to attachment preview field. Nothing happened. When I add an image to image preview field, no preview is shown.

The HTML generated for my image preview input is:

<div class="col-md-6">
<label class="image_preview required col-sm-5 control-label" for="staff_profile_attributes_profile_picture_attributes_image">
<abbr title="required">*</abbr> Profile Picture</label>
<div class="col-sm-7">
<input class="image_preview required" type="file" name="staff[profile_attributes][profile_picture_attributes][image]" id="staff_profile_attributes_profile_picture_attributes_image" data-validate="true">
<p class="help-block">Only accepts JPG, JPEG, PNG, GIF format. Do not exceed 2MB.</p>
</div>
</div>

It does not have preview_version setup either.

Then, in my staffs#edit page, I have the same setup. This time, still no link for attachment preview. But there is a preview for image preview field. However, when I change to a new image, it does not refresh the preview.

I did not do any additional setup. I tried:


SimpleForm::FormBuilder.map_type :image_preview, to: SimpleForm::Inputs::ImagePreviewInput
SimpleForm::FormBuilder.map_type :attachment_preview, to: SimpleForm::Inputs::AttachmentPreviewInput

and it doesn't work. I don't think it is related to this issue.

Am I missing some front end setups such as putting some JS file in application.js?

Please help! Thank you!

I am using Rails 4.2.6, Ruby 2.2.3, Simple_form 3.2.1, client_side_validations 4.2.3 and bootstrap 3.3.6

oasisweng avatar Apr 23 '16 22:04 oasisweng