0

I have a form which is submitted through stimulus controller.

#form.html.haml

= form_with url: my_url, multipart: true, data: { turbo_frame: 'document_table_content', turbo_action: 'advanced' } do |f|
  = f.file_field 'documents[files]', multiple: true, direct_upload: true, data: { 'dropzone-target' => 'input' }

#dropzone_controller.js

Rails.fire(this.form, "submit");

This works, I want additionally after submit to reset the file_field, I have the target through this.inputTarget but I don't know how to remove all files from this form field.

1 Answers1

0

It has always seemed strange to me, but to achieve the reset of the file input you have to reset the form!

document.querySelector('form').reset()
Les Nightingill
  • 5,662
  • 1
  • 29
  • 32