【发布时间】:2012-11-23 11:45:05
【问题描述】:
我有一个包含实体集合(children)的学说实体。 现在我想计算实体并打印出计数。 像这样的:
<div class="item">
<h1>{{ object.name }}</h1>
<div class="childrenCount">children {% count (object.children) %}</div>
</div>
我发现了一些不起作用的示例(like using a "count" filter 导致“未找到过滤器”错误)。
【问题讨论】:
-
object.children|length应该可以工作,确切的错误信息是什么? -
消息是“未找到过滤器“长度”。'
-
完整:使用 count 它是:过滤器“count”在第 10 行的 OurBuyBundle:Mail:bill.html.twig 中不存在
-
没有
count过滤器,但有一个length过滤器。你用的是哪个版本的树枝? -
发现“count”实际上不存在:forum.symfony-project.org/viewtopic.php?t=37282&p=123891 而“length”是一个错字——多么“尴尬”。
标签: php templates doctrine-orm twig symfony-2.1