public function createAction(){ $type = new Type(); $match = new Match(); $match->getId(3); $type->setNumberOfPoints(0); $type->setUser($this->getUser()); $type->setMatch($match); $em = $this->getDoctrine()->getManager(); $em->persist($type); $em->flush(); }
Blad ktory otrzymyje jest nastepujacy:
A new entity was found through the relationship 'My\TyperkaBundle\Entity\Type#match' that was not configured to cascade persist operations for entity: . To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}).
Relacje miedzy encja Type i Match mam taka:
// Type.php class Type { /** * @ORM\ManyToOne( * targetEntity = "Match", * ) * * @ORM\JoinColumn( * name = "match_id", * referencedColumnName = "id", * onDelete = "SET NULL" * ) */ private $match;