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();
}
}
Just add __toString()
method in your Blog
entity
class Blog {
//...
function __toString() {
return $this->getTitle(); // or any other field
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.