Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to set selected in a HTML Select Tag with VIewHelper

Hi,

Im triing to preselect a Select Tag in Volt.

What I get so far:

 {{ select('langId', langs, 'using': ['id', 'name'], 'useEmpty': false,'ng-model':"orderProp") }}

I will no emtpy option. But the generated Code looks like this:

<select id="langId" name="langId" ng-model="orderProp" class="ng-pristine ng-valid">
    **<option value="? undefined:undefined ?"></option>**
    <option value="1">English</option>
</select>

IN the Docs i found nothing at: http://docs.phalconphp.com/en/1.2.6/reference/volt.html#using-tag-helpers or here: http://docs.phalconphp.com/en/1.2.6/reference/tags.html#making-select-boxes

Can please anyone help me?

Thanks.



294
Accepted
answer
edited Mar '14

try using $this->tag->setDefault('langId', '1'); ('langId' as name of your tag and '1' as value you want selected by default) in your controller action

Thaaanks digitronac!