0

When I try to save an Entity linked with a many to many relation with the Media Entity of Sonata i get the error: Entity Was not configured to cascade persist

I have created the Entity class between the two tables, named EntityMedias.

Now I have Entity -1----N- EntityMedias -N----1- Media

And the annotations are set in the EntityMedias two manytoone relations, one related to Entity and the other one related to Media.

How can I configure the Entity with cascade Persist? I have tried to add the option cascade=persist to the column notation, but it doesn't work.

In EntityAdmin I used sonata_type_collection to show the $entityMedias relation inside the Entity.

All work fine if I don't add any media to the new Entity.

Any help will be apreciated

Thank you!

jdivins
  • 549
  • 4
  • 3

1 Answers1

0

You have to observe the syntax for Doctrine to actually pick this up. If you have

/**
 * @ORM\ManyToMany(targetEntity="Entity", mappedBy="medias") 
 */
protected $medias;

you would have to turn this into that:

/**
 * @ORM\ManyToMany(targetEntity="Entity", mappedBy="medias", cascade={"persist"}) 
 */
protected $medias;

I took this from the relevant documentation here and here.

likeitlikeit
  • 5,563
  • 5
  • 42
  • 56