We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Volt select with Order By ?

I have following syntax on the volt template.

I need to know how do i ORDER the select box values using the Table column called "country_sort" ASC ?

                                               {{ select(
                                                'country',
                                                countries ,
                                                'using': ['country_id','country_title'],
                                                'onchange': 'showState()',
                                                'class' : 'required',
                                                'useEmpty': 'true',
                                                'emptyText' : 'Please Choose',
                                                'emptyValue' : ''
                                                ) }}

i cant find a way to do this via Volt. I have seen other solutons like selecting them in the contorllers or usin echo Phalcon\Tag\Select::..etc but thats not what i want.



31.3k
edited Feb '16

In your controller:

countries = A::find(['order' => 'country_sort'])


13.4k
edited Feb '16

thanks