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



85.5k
edited Jan '16

what is this geo_country ?



13.4k

it's the table name.

what is this geo_country ?



85.5k

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.phalcon.io/discussion/2486/multiple-fields-order-and-using-in-phalcon-tag-select



43.9k
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.