Symfony “关键”;“创建数据”;对于带有键的数组";0,1“;在第7行的note/show.html.twig中不存在

Symfony “关键”;“创建数据”;对于带有键的数组";0,1“;在第7行的note/show.html.twig中不存在,symfony,twig,Symfony,Twig,我可以显示所有其他表的createdAt字段,除了我的show视图中的这一个。代码是 {% block body %} <div class="row"> <div class="col-md-12"> <h1>{{ title }}</h1> <small>Criado {{ notes.createdAt | date('d/m/Y') }}</small

我可以显示所有其他表的
createdAt
字段,除了我的
show
视图中的这一个。代码是

{% block body %}
    <div class="row">
        <div class="col-md-12">
            <h1>{{ title }}</h1>
            <small>Criado {{ notes.createdAt | date('d/m/Y') }}</small>
            {% if notes.updatedAt != notes.createdAt %}
                <small>Editado {{ notes.updatedAt | date('d/m/Y') }}</small>
            {% endif %}
        </div>
    </div>
    ...
findAllByBudget
方法是在存储库中创建的:

public function findAllByBudget($id)
{
    $qb = $this->createQueryBuilder('n');

    return $qb
            ->orderBy('n.id', 'DESC')
            ->where(
                $qb->expr()->eq('n.budget', '?1')
            )
            ->setParameter(1, $id)
            ->getQuery()
            ->getResult();
}

不知何故,我在仅显示此特定实体时遇到问题。

您将获得一个注释数组,因此在细枝模板中,您必须使用一些循环来显示每个注释。例如:

    <div class="col-md-12">
        <h1>{{ title }}</h1>
        {% for note in notes %}
            <small>Criado {{ note.createdAt | date('d/m/Y') }}</small>
            {% if note.updatedAt != note.createdAt %}
                <small>Editado {{ note.updatedAt | date('d/m/Y') }}</small>
            {% endif %}
        {% endfor %}
    </div>

{{title}}
{注释%中注释的%s}
Criado{{note.createdAt|date('d/m/Y')}
{%if note.updatedAt!=note.createdAt%}
Editado{{note.updatedAt|date('d/m/Y')}
{%endif%}
{%endfor%}

您将获得一个注释数组,因此在twig模板中,您必须使用一些循环来显示每个注释。例如:

    <div class="col-md-12">
        <h1>{{ title }}</h1>
        {% for note in notes %}
            <small>Criado {{ note.createdAt | date('d/m/Y') }}</small>
            {% if note.updatedAt != note.createdAt %}
                <small>Editado {{ note.updatedAt | date('d/m/Y') }}</small>
            {% endif %}
        {% endfor %}
    </div>

{{title}}
{注释%中注释的%s}
Criado{{note.createdAt|date('d/m/Y')}
{%if note.updatedAt!=note.createdAt%}
Editado{{note.updatedAt|date('d/m/Y')}
{%endif%}
{%endfor%}