简体   繁体   中英

Sonata Admin Bundle listbox sort order

I have 2 entities one referenced to another with many to one relation. For example, User and City. I need listbox with Cities in User edit page to be sorted by Name, not by Id.

How can I do it?

In your Entity, you can specify the ordering .

Example :

<?php
/**
 * @ManyToMany(targetEntity="Group")
 * @OrderBy({"name" = "ASC"})
 */
private $groups;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM