Nested foriloops with account_collection

Hello,

I am working on a template which requires 2 foriloops in combination with an account_collection.
The code below works, however if I change an inputfield, it also overwrites the same account in the following loop.

{% fori best in custom.bezoldigingstest %}{% input best.naam %} {% input best.rekeningen as:account_collection range:61 accounts_var:bez_rek %}

{% fori rek in bez_rek %}{% if forloop.first %}
|Rek.nummer|Rek.naam|Bedrag|
|------|------|------:+{% endif %}
|{{ rek.number }}|{% input rek.custom.bezoldiging.omschrijving default:rek.name%}|{% input rek.custom.bezoldigings.bedrag as:currency default:rek.value%}{% endfori %}

{% endfori %}

I suppose I should include a key for the second foriloop, however i can’t get it to work properly.
Is there a way to do this?

Hi @b.dalle,

You should indeed use a key from the first foriloop (best.key). This should work:

{% fori best in custom.bezoldigingstest %}
  {% input best.naam %} 
  {% input best.rekeningen as:account_collection range:1 accounts_var:bez_rek %}

  {% fori rek in bez_rek %}
    {% if forloop.first %}
      |Rek.nummer|Rek.naam|Bedrag|
      |------|------|------:+
    {% endif %}
    |{{ rek.number }}
    |{% input rek.custom.[best.key].omschrijving default:rek.name %}
    |{% input rek.custom.[best.key].bedrag as:currency default:rek.value%}
  {% endfori %}
{% endfori %}

Should you have any other queries, please let us know.

Best,
Borja

1 Like

Works like a charm! Thx Borja!

1 Like