# Fori with pre-defined values

**URL:** https://community.silverfin.com/t/fori-with-pre-defined-values/937
**Category:** Templates
**Tags:** iterations, for\_loop, fori\_loop
**Created:** [May 28, 2018, 7:38am UTC](https://community.silverfin.com/t/fori-with-pre-defined-values/937 "2018-05-28T07:38:46Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Bart\_Verhaeghe](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@Bart\_Verhaeghe](https://community.silverfin.com/u/Bart_Verhaeghe)
#### Post date: [May 28, 2018, 7:38am UTC](https://community.silverfin.com/t/fori-with-pre-defined-values/937/1 "2018-05-28T07:38:46Z")

</div>

Hi,

Is it possible to add certain values in an input field in addition to certain pre-defined values (from an array)?

Example:

{% assign str\_ExiWetVer = ‘Christophe|Delphine’ %}  
{% assign arr\_ExiWetVer = str\_ExiWetVer | split:’|’ %}

{% fori WetVer in arr\_ExiWetVer %}  
{% input WetVer.name %}  
{% endfori %}

This doesn’t give anything, but is it possible?

Thanks!

---

<div class="post-metadata">

### Author: ![robindeclercq](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/robindeclercq/32/472_2.png) [@robindeclercq](https://community.silverfin.com/u/robindeclercq)
#### Post date: [May 28, 2018, 8:25am UTC](https://community.silverfin.com/t/fori-with-pre-defined-values/937/2 "2018-05-28T08:25:56Z")

</div>

Hi @Bart_Verhaeghe,

Would it be possible to further explain your question in order to avoid misunderstandings?

Do you want a dropdown with the two values of the array, or do you want input fields with the values of the array as defaults?

Thanks!

---

<div class="post-metadata">

### Author: ![Bart\_Verhaeghe](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@Bart\_Verhaeghe](https://community.silverfin.com/u/Bart_Verhaeghe)
#### Post date: [May 28, 2018, 8:28am UTC](https://community.silverfin.com/t/fori-with-pre-defined-values/937/3 "2018-05-28T08:28:07Z")

</div>

Hi Robin,

I’d like to have input fields where the first two fields have the values indicated in the array (so the first two input boxes would have the values ‘Christophe’ and ‘Delphine’ and the third one would be empty in the beginning …

Thanks!

---

<div class="post-metadata">

### Author: ![robindeclercq](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/robindeclercq/32/472_2.png) [@robindeclercq](https://community.silverfin.com/u/robindeclercq)
#### Post date: [May 28, 2018, 9:59am UTC](https://community.silverfin.com/t/fori-with-pre-defined-values/937/4 "2018-05-28T09:59:40Z")

</div>

Hi @Bart_Verhaeghe,

To resolve your query, you should use a combination of a for loop and fori loop.

In order to have the first two input boxes with the values from your array (in this case ‘Christophe’ and ‘Delphine’), a for loop can be used.

> {% assign str\_ExiWetVer = “Christophe|Delphine” %}  
> {% assign arr\_ExiWetVer = str\_ExiWetVer | split:“|” %}  
> {% for WetVer in arr\_ExiWetVer %}  
> {% input custom.name.[forloop.index0] default:WetVer %}  
> {% endfor %}

In order to avoid problems when there is a duplicate name in the array, the input value ‘custom.name.[forloop.index0]’ is used. The name of the input field will always be unique (i.e. custom.name.0, custom.name.1, etc. ).

For the free input a normal fori loop should be used, e.g.:

> {% fori WetVer in custom.test %}  
> {% input WetVer.name %}  
> {% endfori %}

Hope this resolves your question!

Kind regards,  
Robin

---

<div class="post-metadata">

### Author: ![Bart\_Verhaeghe](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@Bart\_Verhaeghe](https://community.silverfin.com/u/Bart_Verhaeghe)
#### Post date: [May 30, 2018, 7:38am UTC](https://community.silverfin.com/t/fori-with-pre-defined-values/937/5 "2018-05-30T07:38:34Z")

</div>

OK this works very well. Thanks Robin!

---

<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: [May 30, 2018, 7:43am UTC](https://community.silverfin.com/t/fori-with-pre-defined-values/937/6 "2018-05-30T07:43:06Z")

</div>


