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!
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!
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!
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
OK this works very well. Thanks Robin!