/**
* @ORM\ManyToMany(targetEntity="Field", inversedBy="clubs")
*/
private $fields;/**
* @ORM\ManyToMany(targetEntity="Club", mappedBy="fields")
*/
private $clubs;The command php app/console doctrine:schema:update will create a club_field table
$club->addField($this->getReference('field'.$field));will be possible because of the order of the relation. To do
$field->addClub($this->getReference('club'.$club));you might have to reverse the relations in the entities, so that the relation table is field_club.
You can do the same with
field_clubandclub_field...Just add
cascade={"persist","remove"}in annotation offieldsandclubsand updateaddFieldandaddClubwith something like this:Off course
setReferenceandgetReferenceare your friends andgetOrdermust be set inFixtures.