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(
                                                'country',
                                                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 ?



67.6k
edited Jan '16

what is this geo_country ?



5.3k

it's the table name.

what is this geo_country ?



67.6k

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 :

https://forum.phalconphp.com/discussion/2486/multiple-fields-order-and-using-in-phalcon-tag-select



31.2k
edited Jan '16

Hi,

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.