Fori with pre-defined values


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


{% assign str_ExiWetVer = ‘Christophe|Delphine’ %}
{% assign arr_ExiWetVer = str_ExiWetVer | split:’|’ %}

{% fori WetVer in arr_ExiWetVer %}
{% input %}
{% endfori %}

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


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?


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 …


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[forloop.index0] default:WetVer %}
{% endfor %}

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

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

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

Hope this resolves your question!

Kind regards,

OK this works very well. Thanks Robin!