Reputation: 609
I am quite new at Symfony and actually I am trying to use my own method from my user.php in the template. it looks like this:
{% for image in app.user.getUserImage %}
...
But the only thing I get is:
An exception has been thrown during the rendering of a template ("Notice: Undefined
index: User
...
Up to now i thought that my user.php (my methods included) is extended to the FOSUserBundle so it can be used in the template.
Do I have to override the FOSUserBundle controller for that reason ?
@MDrollette:
from user.php:
/**
* Get userimage
*
* @return Doctrine\Common\Collections\Collection
*/
public function getUserimage()
{
return $this->userimage;
}
/**
* @ORM\OneToMany(targetEntity="UserImage", mappedBy="User")
* @var ArrayCollection $userimage
*/
protected $userimage;
Upvotes: 1
Views: 409
Reputation: 3407
@ORM\OneToMany(targetEntity="UserImage", mappedBy="User")
I think mappedBy refers to the name of the field in your UserImage entity and not to the User entity itself.
Cheers
Upvotes: 1
Reputation: 11122
You need to use app.user.userimage, as that's the property name. That will automatically call the getter for the property (getUserImage).
Upvotes: 1