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());
    }

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

猜你喜欢

转载自blog.csdn.net/qq_36110571/article/details/104777173
今日推荐