Reputation: 93
I've got this error while continuing with
tutorial.symblog.co.uk[Part 4]-
The Comments Model: Adding comments, Doctrine Repositories and Migrations]
An exception has been thrown during the rendering of a template ("A "__toString()" method was not found on the objects of type "Blogger\BlogBundle\Entity\Blog" passed to the choice field. To read a custom getter instead, set the option "property" to the desired property path.") in BloggerBlogBundle:Blog:show.html.twig at line 23.
does any one got a clue on this?
// src/Blogger/BlogBundle/Entity/Blog.php
namespace Blogger\BlogBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity(repositoryClass="Blogger\BlogBundle\Entity\Repository\BlogRepository")
* @ORM\Table(name="blog")
* @ORM\HasLifecycleCallbacks()
*/
class Blog {
//..........
public function __toString() {
return $this->getTitle();
}
}
Upvotes: 0
Views: 813
Reputation: 1359
Just add __toString()
method in your Blog
entity
class Blog {
//...
function __toString() {
return $this->getTitle(); // or any other field
}
}
Upvotes: 3