0

I have an Entity with two CollectionType but when I dump this entity I just have one with the ArrayCollection.

enter image description here

enter image description here

In my orderproductType I put this code :

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('dimension')
        ->add('product', CollectionType::class, array(
            'entry_type' => ProductType::class,
            'allow_add' => true,
        ))
        ->add('machining', CollectionType::class, array(
            'entry_type' => MachiningType::class,
            'allow_add' => true,
        ))
        ->add('save', SubmitType::class)
    ;
}

And in my entity :

 /**
 * @ORM\OneToMany(targetEntity="ProductBundle\Entity\Product", mappedBy="Orderproduct")
 */
private $product;

/**
 * @ORM\OneToMany(targetEntity="ProductBundle\Entity\Machining", mappedBy="Orderproduct")
 */
private $machining;
  • add / remove and get.

Any idea ?

Thx

Wako
  • 63
  • 1
  • 9
  • In the entity constructor, you assign both attributes a `new ArrayCollection`? Also, why is this important - does it break your code? – kero May 08 '17 at 09:57
  • @kero I've got this error `A new entity was found through the relationship 'ProductBundle\Entity\Orderproduct#product' that was not configured to cascade persist operations for entity: ` – Wako May 08 '17 at 10:01
  • Or it's simply my relation ? Need to change for ManyToOne in product and Machining ? – Wako May 08 '17 at 10:06
  • 2
    This error has nothing to do with array or ArrayCollection. See [answers like this](http://stackoverflow.com/questions/18215975/doctrine-a-new-entity-was-found-through-the-relationship) – kero May 08 '17 at 10:08
  • Thx for your help ! – Wako May 09 '17 at 07:08

0 Answers0