I have a fairly simple doctrine representing the news; this news can be associated with many pictures, so I decided to use the Doctrine collection. The thing is, I want to get these photos and display them in my template ... But that didn't seem to work. Do you know how I can do this?
Here is what I tried:
{% for annonce in annonces %}
<div class="annonce_item">
{% for photo in annonce.photo %}
<img src="{{ photo.path }}" alt="" />
{% endfor %}
</div>
{% endfor %}
annonce is a news class, and a photo is a collection:
/**
* @ORM\OneToMany(targetEntity="Photo", mappedBy="id",cascade={"persist"})
*/
private $photo;
When I try to display this page in my browser, I get this exception:
( ": Undefined index: > id in > /Applications/MAMP/htdocs/ApacheImmobilier/vendor/doctrine/lib/Doctrine/ORM/Persisters/Basi > cEntityPersister.php line 1274" ) "APPagesBundle: Index: index.html.twig" 45.
!