M schema.yml:
News:
columns:
title:
type: string(50)
category_id:
type: integer(4)
relations:
Category:
local: category_id
foreign: category_id
type: one
Category:
columns:
category_name:
type: string(50)
generator:
class: sfDoctrineGenerator
param:
model_class: News
theme: admin
non_verbose_templates: true
with_show: false
singular: ~
plural: ~
route_prefix: news
with_doctrine_route: true
actions_base_class: sfActions
config:
actions: ~
fields: ~
list:
display: [news_id, title, category_name]
filter:
display: [news_id, title, category_id]
form: ~
edit: ~
new: ~
In news.class:
public function getCategoryName()
{
return $this->getCategories()->getCategoryName();
}
This works, but I can't sort this field. I can sort by id, title, category_id, but not by category_name. How can I sort by this custom column?