我有以下模型的管理生成器:
#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>
谢谢