簡體   English   中英

當模型與user_id關聯時,symfony管理員列表視圖按用戶名排序

[英]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-generatePoster模式。 現在,在“列表”視圖中,我可以看到user_id為1,2等,在過濾器中,我可以看到一個下拉菜單,可讓我選擇用戶名。 現在,我想要一個username user_id段而不是user_id在其中可以顯示關聯用戶的username ,並且希望此列可sortable

在過濾器方面,我希望有一個文本字段,它不僅可以進行精確匹配,還可以進行部分匹配,即如果我使用x過濾,則xyz也應包含在結果中。

我已經在一些論壇上看到了有關這些的一些提示,但是這些都是點點滴滴,大部分是在我使用Doctrine用於Propel的。

任何幫助表示贊賞。 提前致謝。

  1. 在genrator.yml中的海報模塊中:

    清單:
    標題:海報展示:[= user,some_field]

  2. 如果您想自定義過濾器,則可以使用join閱讀symfony admin過濾器並嘗試做

UPD

它是解決方案:

Symfony 1.4管理生成器在自定義列上排序

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM