Hi there,
I am building a select input in a form. Each option of the select input comes from an array pageData.assetTypes
, and I have a default value stored as a string in pageData.type
.
If my default value exists, I want it to be selected by default in my select input. I have done the following:
{{#if pageData.type}} {{#each pageData.assetTypes}} {{#eq pageData.type this}} <option value="{{this}}" selected>{{this}}</option> {{else}} <option value="{{this}}">{{this}}</option> {{/eq}} {/each}} {{else}} <option value="" selected disabled hidden>Choose here</option> {{#each pageData.assetTypes}} <option value="{{this}}">{{this}}</option> {{/each}} {{/if}}
I’m loosing the pageData.type
value when entering the {{#each}}
loop. Am I doing something wrong?
Cheers
Jules