Symfony管理员生成器,链接到过滤结果

| 我有以下模型的管理员生成器:
#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:     ~
<!-- modules/author/templates/_booksLink.php -->
<a href=\"<?= link_to(\'book?author_id=\'.$author->getId()) ?>\"><!-- how to select filter? -->
  See <?= $author->getName() ?> books
</a>
谢谢     
已邀请:
        本讲座回答您的问题(幻灯片39和40): http://www.slideshare.net/jcleveley/working-with-the-admin-generator 在您的actions.class php中添加:
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
。如果架构中有“ 7”,则必须在函数中编写“ 7”。另外,模块名称总是带小写的下划线(例如:
schema : MyBooks -> module name: my_books
)。 在您的generator.yml中
list: 
  object_actions:
    _edit: ~
    _delete: ~
    viewPhones: { label: View books, action: viewBooks } 
    

要回复问题请先登录注册