Skip to content

Twig templates & Doctrine proxy object - symfony 2.2.0-RC2 #7122

@zd-dalibor

Description

@zd-dalibor

If you have for example "Item" entity with many to one relation between them and "Group" entity. In "Item" entity "group" parameter represents "Group" entity where it belongs with getter "getGroup" and setter "setGroup". "Group" consists "title" parameter with getter "getTitle" and setter "setTitle"

In controller for example you find one item with item id and pass that item to twig template as variable "item". In "item" object "group" parameter is now doctrine proxy object.

If you try to do this in twig template

{{ item.group.title }}

you will get this error

Twig_Error_Runtime: Item "title" for "Array" does not exist in "<some_twig_template>" at line <some_line>

Only parameter that twig can access in "item.group" object is "isInitialized".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions