How to make independent input fields inside a for loop

Hi there,

Could you please advise how can I make the input fields in the “Comments” and “Attachments” columns independent? I coded those input cells inside the for loop,but when the user select a new account, the comment cells and attachments will be overridden.

Please see the screenshot and coding below:

{% assign additional_items_range = additional_items_range | default:“1491,1492,1591,1592,2491,2492,2591,25923991,3992” %}

{% stripnewlines %}
|
|Account
|Comments
|Attachment
{% newline %}
|:—3%-----
|:----25%----
|:----70%----
|:—2%-----#{% ic %}{% endic %}+
{% newline %}
|{% input custom.additional_items.toSelect as:account_collection range:additional_items_range accounts_var:additional_items | currency_dc %}
{% newline %}
{% for additional in additional_items %}
|
|{% capture additional_account_link %}{% linkto additional %}{{ additional.original_number }} {{ additional.original_name }}{% endlinkto %}{% endcapture %}
{{ additional_account_link }}
{{ additional_account_name }}
| {% input custom.additional.toSelect as:text placeholder:‘Description’ %}
|{% input custom.account_file.toSelect as:file_collection %}
{% newline %}
{% endfor %}
{% endstripnewlines %}

Thank you!

Hi Flora,

The text and file inputs are part of a forloop, so they need to be unique for each loop, if not they will be reproduced every line.

Since you are looping over accounts, I suggest to use the account id as a key.

{% capture account_id %}{{ additional.id }}{% endcapture %}
|{% input custom.[account_id].toSelect as:text placeholder:‘Description’ %}
|{% input custom.[account_id].File_toSelect as:file_collection %}

Furthermore remark that there is no need to use a currencyfilter for an account collection input field.

Kind regards,

Michiel

1 Like

Hi Michiel,

This solution works for me, thank you for your help!

Kind regards,