title: symfony3 CollectionType OneToMany
body: <p>I have 2 entities: person and emailaddress</p>
  
  <pre><code>class Person
  {
  
  /**
       * @var int
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @var string
       *
       * @ORM\Column(name="name", type="string", length=255)
       */
      private $name;
  
      /**
       * @var Emailaddress[]
       * @ORM\OneToMany(targetEntity="Emailaddress", mappedBy="person", cascade={"ALL"})
       *
       */
      private $emails;
  
  
      public function __construct() {
          $this-&gt;emails = new ArrayCollection();
      }
  
      /**
       * Get id
       *
       * @return int
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set name
       *
       * @param string $name
       *
       * @return Person
       */
      public function setName($name)
      {
          $this-&gt;name = $name;
  
          return $this;
      }
  
      /**
       * Get name
       *
       * @return string
       */
      public function getName()
      {
          return $this-&gt;name;
      }
  
      /**
       * Add email
       *
       * @param \AppBundle\Entity\Emailaddress $email
       *
       * @return Person
       */
      public function addEmail(\AppBundle\Entity\Emailaddress $email)
      {
          $this-&gt;emails[] = $email;
          $email-&gt;setPerson($this);
  
          return $this;
      }
  
      /**
       * Remove email
       *
       * @param \AppBundle\Entity\Emailaddress $email
       */
      public function removeEmail(\AppBundle\Entity\Emailaddress $email)
      {
          $this-&gt;emails-&gt;removeElement($email);
      }
  
      /**
       * Get emails
       *
       * @return \Doctrine\Common\Collections\Collection
       */
      public function getEmails()
      {
          return $this-&gt;emails;
      }
  }
  
  class Emailaddress
  {
      /**
       * @var int
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @var string
       *
       * @ORM\Column(name="emailaddress", type="string", length=100)
       */
      private $emailaddress;
  
      /**
       * @var Person
       * @ORM\ManyToOne(targetEntity="Person", inversedBy="emails")
       * @ORM\JoinColumn(name="person_id", referencedColumnName="id")
       */
      private $person;
  
      /**
       * Get id
       *
       * @return int
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set emailaddress
       *
       * @param string $emailaddress
       *
       * @return Emailaddress
       */
      public function setEmailaddress($emailaddress)
      {
          $this-&gt;emailaddress = $emailaddress;
  
          return $this;
      }
  
      /**
       * Get emailaddress
       *
       * @return string
       */
      public function getEmailaddress()
      {
          return $this-&gt;emailaddress;
      }
  
      /**
       * Set person
       *
       * @param \AppBundle\Entity\Person $person
       *
       * @return Emailaddress
       */
      public function setPerson(\AppBundle\Entity\Person $person = null)
      {
          $this-&gt;person = $person;
  
          return $this;
      }
  
      /**
       * Get person
       *
       * @return \AppBundle\Entity\Person
       */
      public function getPerson()
      {
          return $this-&gt;person;
      }
  }
  </code></pre>
  
  <p>In EmailaddressType I have:</p>
  
  <pre><code>$builder-&gt;add('email');
  </code></pre>
  
  <p>And in PersonType:</p>
  
  <pre><code>$builder-&gt;add('name')
          -&gt;add('emails', CollectionType::class, array(
                  'entry_type'   =&gt; EmailAddressType::class,
                  'allow_add' =&gt; true,
       ));
  </code></pre>
  
  <p>Now when the form is generated on the emails field does not display anything.
  How can I generate email fields?</p>
  
  <p>Thanks</p>