title: Array to CollectionType in Symfony 3.4 forms
body: <p>I've got the array Cart of the entities, and I want to generate general form, which looks like on the screen.</p>
  
  <p><a href="https://i.stack.imgur.com/dNmuQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dNmuQ.png" alt="enter image description here"></a></p>
  
  <p>As you see, I want to have editable field Quantity in each row, which represents the Cart entity, and I want to have ability to update all of them at once.</p>
  
  <pre><code>class Cart
  {
  /**
   * @ORM\Id
   * @ORM\Column(type="integer")
   * @ORM\GeneratedValue(strategy="AUTO")
   */
  private $id;
  
  /**
   * @ORM\ManyToOne(targetEntity="User", inversedBy="carts")
   */
  private $userId;
  
  /**
   * @ORM\ManyToOne(targetEntity="Product", inversedBy="carts")
   */
  protected $product;
  
  /**
   * @ORM\Column(type="integer")
   */
  private $quantity;
  
  /*gettes &amp; setters */
  }
  </code></pre>
  
  <p>For now, I have form, which wants to receive CollectionType, to work on it, but - I have only an array of entities, so It's dumping LogicalException.</p>
  
  <p>What I need to do - there is any way to parse array to CollectionType, or maybe I could take group of cart entities from database in another way than that?:</p>
  
  <pre><code>$carts=$this-&gt;getDoctrine()-&gt;getRepository(Cart::class)-&gt;findByUserId($user);
  </code></pre>