[英]symfony admin list view Sort by username when the model is associated with user_id
我正在使用sfDoctrineGuardPlugin
。 我有一個模型Poster
,其中有一個user_id
字段鏈接到sfGuardUser
表的id
字段。
Poster:
actAs:
Timestampable: ~
Sluggable:
fields:[name]
columns:
id:
type: integer(4)
autoincrement: true
primary: true
name:
type: string(255)
notnull: true
filename:
type: string(255)
notnull: true
approved:
type: boolean(1)
default: false
user_id:
type: integer(20)
default: 1
attributes:
export: all
validate: true
relations:
User:
class: sfGuardUser
local: user_id
foreign: id
type: one
foreignType: many
foreignAlias: Posters
我有一個模塊poster
是由生成的doctrine:admin-generate
了Poster
模式。 現在,在“列表”視圖中,我可以看到user_id
為1,2等,在過濾器中,我可以看到一個下拉菜單,可讓我選擇用戶名。 現在,我想要一個username
user_id
段而不是user_id
在其中可以顯示關聯用戶的username
,並且希望此列可sortable
。
在過濾器方面,我希望有一個文本字段,它不僅可以進行精確匹配,還可以進行部分匹配,即如果我使用x
過濾,則xyz
也應包含在結果中。
我已經在一些論壇上看到了有關這些的一些提示,但是這些都是點點滴滴,大部分是在我使用Doctrine
用於Propel的。
任何幫助表示贊賞。 提前致謝。
在genrator.yml中的海報模塊中:
清單:
標題:海報展示:[= user,some_field]
如果您想自定義過濾器,則可以使用join閱讀symfony admin過濾器並嘗試做
UPD
它是解決方案:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.