# CASE: how to display multiple inputs for each loop of a collection?

**URL:** <https://community.silverfin.com/t/case-how-to-display-multiple-inputs-for-each-loop-of-a-collection/410>\
**Category:** Cases\
**Created:** [September 18, 2017, 2:40pm UTC](https://community.silverfin.com/t/case-how-to-display-multiple-inputs-for-each-loop-of-a-collection/410 "2017-09-18T14:40:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [September 18, 2017, 2:40pm UTC](https://community.silverfin.com/t/case-how-to-display-multiple-inputs-for-each-loop-of-a-collection/410/1 "2017-09-18T14:40:38Z")

</div>

Let’s say we have following template :

 ![49](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/127be55a73f2882e4573a84d04b8f6aaa6078131.png)

with this code :

```auto
*Select accounts here* {% input period.custom.accounts.costs as:account_collection range:61 accounts_var:costs %}

<br> 

{% stripnewlines %}
{% newline %}
| Number | Name | Supplier | Remark
{% newline %}
|---10%-----------|---40%--------|----25%------------|-----25%-----------+
{% for acc in costs %}
  {% newline %}
  |{{ acc.number }} 
  |{{ acc.name }}
  |{% input acc.custom.costs.supplier %}
  |{% input acc.custom.costs.remark %}
{% endfor %}
{% endstripnewlines %}

```

But what if we would like to give in multiple suppliers for each account? Because now with this code you can give only 1 input, and not several.

**Create extra fori-loop in each loop**

For each iteration of a loop, we’re gonna need to create a new fori-loop to input multiple suppliers. And we have to ask ourselves, what makes each loop unique?  
The answer is a variable in each loop: the accountnumber.

If we create a collection that is “attached” to that accountnumber, we can create input-variable with a fori-loop:

```auto
  {% newline %}
  |{{ acc.number }} 
  |{{ acc.name }}
  |
    {% fori supp in custom[acc.number] %}
      {% input supp.name %}
    {% endfori %}

```

So, the custom[acc.number] is our collection that is unique for each loop, because it’s attached to the object `acc.number` . Because the `acc.number` is a variable, we use [] to create that collection.

However, you may see something like this now :

 ![17](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/975a8690dd40ef203a7f7259f78fc57ecd2c2b14.png)

And we need our input to be on a new line for each input, so we’re use the break-tag   
 for that:

```auto
  {% newline %}
  |{{ acc.number }} 
  |{{ acc.name }}
  |
    {% fori supp in custom[acc.number] %}
      <br>{% input supp.name %}
    {% endfori %}
  |{% input acc.custom.costs.remark %}

```

That break-tag however, can’t be executed or it will result in this :

 ![29](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/4a48743db95029740235c2eda31fcef8e7a1e896.png)

So only in the first iteration of the loops, the break tag can’t be used. We can do this with a forloop.first and an unless-statement:

```auto
  {% newline %}
  |{{ acc.number }} 
  |{{ acc.name }}
  |
    {% fori supp in custom[acc.number] %}
      {% unless forloop.first %}
      <br>
      {% endunless %}
      {% input supp.name %}
    {% endfori %}
  |{% input acc.custom.costs.remark %}

```

This will give the result we need :

 ![32](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/11c9c635ad675f034e9246de9397a9262b9d68a2.png)

PS for more info about forloop.first, check this [topic](https://community.silverfin.com/t/case-how-to-use-if-forloop-first-and-or-if-forloop-last/21/2) about it.
