symfony或doctrine报错:Object of class App\Entity\* could not be converted to string

报错:

Catchable Fatal Error: Object of class App\Entity\ProjectType could not be converted to string

版本:symfony5.0

解决办法:

在对应的Entity里添加public __toString方法,我这里就是App\Entity\ProjectType类

// App\Entity\ProjectType 
    public function __toString(){
        return strval($this->getId());
    }

具体原因:可以  > 看这里 <    |    > 这里 <

posted @ 2020-03-10 16:32  我的五年  阅读(14)  评论(0)    收藏  举报  来源