[Solved] Put specified index from an array in the top of select box


I would suggest to just mark “Turcia” as selected.

Handlebars Helper: (Javascript version)

Handlebars.registerHelper('eq', function(a, b, block) {
    return a == b ? block.fn(this) : block.inverse(this);
});

Template:

{{#each oForm.lCountry}}
    <option value="{{@key}}" {{#eq this 'Turcia'}}selected="true"{{/eq}}>
      {{this}}
    </option>
{{/each}}

Output:

<option value="2" >
    Afganistan
</option>
...
<option value="6" selected="true">
    Turcia
</option>

Now “Turcia”, will be selected by default. Which is more logical so you can mantain the alphabetical order.

If you want “Turcia” to appear first by any means, just change the order of the array in PHP.

solved Put specified index from an array in the top of select box