Upload files in fori-loop with unique keys

Hello everyone,

I’m having a problem uploading files within the fori loop. We created a fori list where users can add a text comment and upload a file. When a user enters a text comment, everything works fine and the comment appears only in that tab. However, when a user uploads a file, it appears in all of the file upload tabs within that category (The creation of a new category in the fori works fine, the only problem is that the file uploads in both ‘file_upload’ and ‘file_upload2’). The keys of the customs are unique.

You can test it out with the following code (when uploading a file, you see the problem) :

{% fori item in custom.comments %}

The first comment and file: {% input item.textual_comment %}{% input item.file_upload as:file %}

The second comment and file: {% input item.textual_comment2 %}{% input item.file_upload2 as:file %}


{% endfori %}

  • Hopefully anyone can explain why this does work for the textual input but doesn’t work for the file input.
  • Does anyone have a solution to this problem?
    • We already thought about making a ‘normal’ custom input (with a assigned variable) for the files, but this would empty the existing uploaded files for non-closed customers.

Thanks in advance for you r time!

Hi @YouriBrouwers

Thanks for reaching out and welcome to the community! :blush:

To answer your question: it’s by design that only one file-input can be linked to a fori-loop. The file attachment happens at the level of the collection itself, not on the level of individual fori-items. So using a custom variable here won’t work around that limitation either.

In short: one file per fori-loop is currently the expected behaviour.

If this is something that would be useful for your workflow, feel free to share it as a feature request we’re always keen to hear what would make Silverfin work better for you!

Kind regards,
Jarne