Undefined index on doctrine m:n relation Undefined index on doctrine m:n relation php php

Undefined index on doctrine m:n relation


I'm having the same trouble, and the answers on StackOverflow while correct dont go deep enough. I found in one of the Doctrine jira issues:

If you run

doctrine:schema:validate

then it will tell you what the problem is.


If I am correct...

Your mappedBy in the class Department should be the property of the NewsItem class, in your case departments in stead of newsItems.


You are probably missing something in your function notations.. have a look at this:

http://www.doctrine-project.org/docs/orm/2.0/en/reference/association-mapping.html#many-to-many-bidirectional

It seems you are missing @JoinTable notation - maybe try to invert Owning and Inverse side?