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

Set "order" of related models

Is there any way to specify the order of related models?

I'm looping through related models of a model in my Volt template, and I want the related models to be sorted alphabetically. Using:

{% for User in LoopDeparment.getUsers(['order'=>'name']) %}

causes an "unexpected ASSIGN" error.



98.9k
Accepted
answer

It must be:

{% for User in LoopDeparment.getUsers(['order': 'name']) %}

Ah. Yep - that works. Thanks.