mkk mkk - 3 months ago 9
PHP Question

Doctrine 2.1: how to set "cascade: persist" using yaml

I get an error when I try to do

$b = new B();
$a->addB($b);
$entityManager->persist($a);


because I first need to persist $b, however I cannot do this, so I need to set cascade: persist I believe. I just cannot find in documentation how to do this using yaml schema.
Documentation does not cover this part ( I tried in other places in documentation as well)

Cheers

mkk mkk
Answer

This works for me

oneToMany:
    products:
      targetEntity: Name
      mappedBy: product
      cascade: ["persist"]