Symfony1 Symfony管理生成器,链接到筛选结果

Symfony1 Symfony管理生成器,链接到筛选结果,symfony1,filter,admin-generator,Symfony1,Filter,Admin Generator,我有一个用于以下型号的管理生成器: #schema.yml Author: columns: name: { type: string(255), notnull: true } Book: columns: authorId: { type: integer, notnull: true } title: { type: string(512), notnull: true } content: { type: string(512), notnull

我有一个用于以下型号的管理生成器:

#schema.yml
Author:
  columns:
    name: { type: string(255), notnull: true }

Book:
  columns:
    authorId: { type: integer, notnull: true }
    title: { type: string(512), notnull: true }
    content: { type: string(512), notnull: true }
  relations:
    Author: { onDelete: CASCADE, local: authorId, foreign: id, foreignAlias: Books}
我有2页,每个表格对应

php symfony doctrine:generate-admin backend Author
php symfony doctrine:generate-admin backend Book
现在我想在作者视图中找到他的书的链接。 最好的方法是什么? 我的尝试是一个自定义链接,预先选择过滤器,但我不知道如何做到这一点

#generator.yml for Author
# ...
    config:
      actions: ~
      fields:
      list:
        display: [id, name, _booksLink]
      filter:  ~
      form:    ~
      edit:    ~
      new:     ~



谢谢

本课回答了您的问题(幻灯片39和40):

在actions.class中添加:


class AuthorActions extends AutoAuthorActions
{
  public function executeViewBooks($request) { 
    $this->getUser()->setAttribute( 'book.filters',   
    array('authorId' => $request->getParameter('id')), 'admin_module' ); 
    $this->redirect($this->generateUrl('book')); 
  }
}
关于案例的说明:字段名与模式中定义的案例匹配。例如:如果模式中有
authorId
,则必须在上面的函数(第5行)中写入
authorId
。如果架构中有
author\u id
,则必须在函数中写入
author\u id
。此外,模块名称总是小写加下划线(例如:
schema:MyBooks->modulename:myu books

在生成器中。yml

list: 
  object_actions:
    _edit: ~
    _delete: ~
    viewPhones: { label: View books, action: viewBooks }

名单:
对象操作:
_编辑:~
_删除:~
可视电话:{标签:查看书籍,操作:查看书籍}

太好了,谢谢你修复它,我总是按照惯例使用下划线符号,我忘了还有其他可能的符号,好主意,到目前为止,我一直在使用一种更黑客的方法来实现这一点。

list: 
  object_actions:
    _edit: ~
    _delete: ~
    viewPhones: { label: View books, action: viewBooks }