8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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".
The text was updated successfully, but these errors were encountered:
Can you copy/paste your entities ? And also show us your controller that retrieve the item ?
Sorry, something went wrong.
In previous example I tried to simplify things. This is the real entities.
User Entity: https://gist.github.com/dalibor983/4985875
CityDefinition Entity: https://gist.github.com/dalibor983/4985914
XML mappings for this two entities: https://gist.github.com/dalibor983/4985919
Controller code
$username = <some_username>; $manager = $this->getDoctrine()->getManager(); $r = $manager->getRepository('<some_bundle>:User'); /* @var User $user */ $user = $r->findOneBy(array('loginUsername' => $username)); return $this->render('<some_twig>', array( 'userData' => $user, ));
Twig consists
{{ userData.cityDefinition.longName }}
@dalibor983 Could you move this code to gist? It makes this issue really unreadable...
The code above works in simfony 2.1 but not in 2.2.0RC2. I'm trying to upgrade from 2.1 to 2.2.0RC2
I updated my post with gist links.
I also use this in twig template:
{{ render(controller("<some_bundle>:Example:index", {"cityDef": userData.cityDefinition})) }}
and in "ExampleController:index" i have
public function indexAction($cityDef 8000 ) { $this->render(<some_twig>, array("cityDef" => $cityDef)); }
and in twig
{{ cityDef.longName }}
I also get error.
I noticed that this twig call:
transformed "userData.cityDefinition" proxy object to array with one element "isInitialized => '1'" and in "ExampleController:indexAction" I got this array for "$cityDef" parameter instead of proxy object.
See issue #7124
No branches or pull requests