Emilian.xyz

Articles and tutorials ...

Hello everyone!

On my website where are you reading this article now ... i have this 2 tables in the MySql Database

  • Categories
  • Articles

Between this 2 tables I 've created a relationship so that one category corresponds to several more articles.

I have created the Admin CRUD with Easyadmin ....

But ... when i wanted to create a new Article, i was getting this error:


Object of class App\Entity\Categories could not be converted to string

... what have i done?

We have on entity called Categories ...

at the end of the file:

src/Entity/Categories

i have added this function:

    
public function __toString()
     {

        return $this->getName();

    }