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

Phalcon Volt SELECT with ORDER BY FIELD ?

I have following code in volt. which i use to genenerat the country list for a select box

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

But i want to generate this by order by field value like

ORDER BY FIELD(country_title, "Canada", "India", "other"), country_id ASC

How do i archieve this expected value ?

edited Jan '16

what is this geo_country ?


it's the table name.

what is this geo_country ?


ah ok my bad, i dont use volt.

but i am not sure you can do that, maybe wait for someone else to respond. The way i use it cna be found here :


edited Jan '16


maybe you can do the db search in the controller (and then use raw sql if ever your query is too complicated for the basic ORM), pass the result to the view as an array and use selectStatic in the view.