/**
* @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_club
andclub_field
...Just add
cascade={"persist","remove"}
in annotation offields
andclubs
and updateaddField
andaddClub
with something like this:Off course
setReference
andgetReference
are your friends andgetOrder
must be set inFixtures
.