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

具體原因:可以  > 看這裏 <    |    > 這裏 <

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