Symfony2-Doctrine: ManyToMany relation is not saved to database Symfony2-Doctrine: ManyToMany relation is not saved to database symfony symfony

Symfony2-Doctrine: ManyToMany relation is not saved to database


Your Category entity is the inverse side of the relationship.

Try changing addItems to look like this:

public function addItem(\Ako\StoreBundle\Entity\Item $item)    {        $item->addCategory($this);        $this->items[] = $item;    }

Note that I changed your plural names to singular, since you're dealing with single entities, not collections.


I had the same problems...I think you forgot

$category->addItems($item);$em->persist($category);$em->flush();