【问题标题】:symfony admin list view Sort by username when the model is associated with user_idsymfony admin list view 模型关联 user_id 时按用户名排序
【发布时间】:2011-12-13 11:29:34
【问题描述】:

我正在与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-generatePoster 模型生成的。现在在列表视图中,我可以看到 user_id 为 1,2 等,在过滤器中,我可以看到一个下拉列表,让我选择用户名。现在,我想要一个username 字段而不是user_id,我可以在其中显示关联用户的username,并且我希望此列是sortable

在过滤器方面,我希望有一个文本字段,它不仅可以进行精确匹配,还可以进行部分匹配,即如果我使用x 进行过滤,xyz 也应该在结果中。

我在一些论坛上看到了一些关于这些的提示,但这些都是零碎的,其中大部分是针对 Propel 而我使用Doctrine

感谢任何帮助。提前致谢。

【问题讨论】:

    标签: php symfony1 doctrine symfony-1.4 symfony-forms


    【解决方案1】:
    1. 在 genrator.yml 的海报模块中:

      列表:
      标题:海报 显示:[=user, some_field]

    2. 如果你想自定义你的过滤器,你可以阅读symfony admin filter with join并尝试去做

    UPD

    解决办法:

    Symfony 1.4 admin generator sort on custom column

    【讨论】:

    猜你喜欢
    • 2017-07-30
    • 1970-01-01
    • 1970-01-01
    • 2018-02-15
    • 2017-02-13
    • 1970-01-01
    • 2018-07-16
    • 2011-05-31
    • 1970-01-01
    相关资源
    最近更新 更多