Click Fraud Protection
PHP related blog, freelancer to hire!

Symfony – Sorting elements in filters (foreign table)

Today i found nice and simple solution how to filter elements in dropdown when you specify filter for field which is forgeign key.

Simple go and edit Peer class of table you want to have things sorted.

class [YOURTABLE]Peer extends Base[YOURTABLE]Peer
{
  public static function addSelectColumns(Criteria $criteria)
  {
    parent::addSelectColumns($criteria);
    $criteria->addAscendingOrderByColumn(self::[FIELD YOU WANT TO SORT BY]);
  }
}
1 Comment
  1. Hi, nice post. I have been thinking about this issue,so thanks for sharing. I will certainly be coming back to your blog.

Leave a Reply