symfony admin 列表视图 当模型与 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
我有一个由 doctrine:admin-generate
为 Poster
模型生成的模块 poster
。现在在列表视图中,我可以看到 user_id
为 1,2 等,在过滤器中,我可以看到一个下拉列表,可以让我选择用户名。现在,我想要一个 username
字段而不是 user_id
,在其中我可以显示关联用户的 username
,我想要这个列可排序
。
在过滤器方面,我希望有一个文本字段,它不仅可以进行精确匹配,还可以进行部分匹配,即如果我使用 x
进行过滤,xyz
也应该是在结果中。
我在一些论坛上看到过一些关于这些的提示,但这都是零散的,其中大部分是在我使用 Doctrine
时用于 Propel 的。
任何帮助表示赞赏。提前致谢。
I'm working with sfDoctrineGuardPlugin
. I have a model Poster
which has a user_id
field linked to the id
field of the sfGuardUser
table.
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
I have a module poster
which is generated by doctrine:admin-generate
for the Poster
model. Now in the List view, I can see the user_id
as 1,2, etc. and in the filters, I can see a dropdown which lets me select the usernames. Now, I would like to have a username
field instead of user_id
in which I can display the username
of the associated user and I would like this column to be sortable
.
On the filter side, I would like to have a text field which not only does exact matching, but also does partial matching i.e. If I filter with x
, xyz
also should be in the results.
I have seen some hints about these on some forums but that is all in bits and pieces and most of it is for Propel while I'm using Doctrine
.
Any help is appreciated. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 generator.yml 的海报模块中:
列表:
标题: 海报
display: [=user, some_field]
如果您想自定义过滤器,您可以阅读< strong>symfony admin 过滤器与 join 并尝试执行
UPD
这是解决方案:
Symfony 1.4 管理生成器在自定义列上排序
In your poster module in genrator.yml:
list:
title: Poster
display: [=user, some_field]
If you want customize your filter, you can read symfony admin filter with join and try to do it
UPD
It is solutions:
Symfony 1.4 admin generator sort on custom column