Form Attachments

Theodoulos Iacovou asked on July 3, 2020 09:12

Hello guys,

I have built a form where contains various of fields and attachments.

Why after of a wrong input(validation error) the attachments files are gone and need to resubmitted them?

Any solution to avoid this?

Thank you

Recent Answers

Dmitry Bastron answered on July 3, 2020 12:03

Hi Theodoulos,

This is a default behavior when backend validation kicks in: form is submitted actually (POST request happens) then model state in FormWidgetController returns false for validation and the system re-draws the form with fields prepopulated. The problem is that the default file upload control cannot pre-populate file selected again.

To solve this you have two options (but both to be honest are not very easy to accomplish):

  1. Customize form validation to use frontend validation instead of backend (will require you writing some custom JS)
  2. Develop your own file upload control that will support pre-population on validation exception:
    • it could be frontend control which when user selects the file actually posts the file to server straight away and stores file ID in the control
    • in this case file ID will remain the same on validation exception and file uploaded will remain the same
    • you would need to deal with re-uploading this file and data cleanse at least
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.