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

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章