Many to one relation : ArrayCollection issue <p><img src="https://i.stack.imgur.com/PTvzx.png" alt="Domain form"></p> <p>I have a many to one relation between Domain and Site. But when I try to add a new domain I have this error :</p> <blockquote> <p>Found entity of type Doctrine\Common\Collections\ArrayCollection on association Eliophot\BackBundle\Entity\Domain#site, but expecting Eliophot\BackBundle\Entity\Site</p> </blockquote> <p>This is my DomainController : </p> <pre><code>public function createDomainAction(Request $request) { $domain = new Domain; if (!$domain) { throw $this-&gt;createNotFoundException('Unable to find Domain entity.'); } $newForm = $this-&gt;createForm(new DomainType(), $domain); $newForm-&gt;handleRequest($request); if ($newForm-&gt;isValid()) { $entityManager = $this-&gt;get('doctrine')-&gt;getManager(); $entityManager-&gt;persist($domain); $entityManager-&gt;flush(); $this-&gt;get('session')-&gt;getFlashBag()-&gt;add('success', 'Le domaine a été crée'); return $this-&gt;redirect($this-&gt;generateUrl('domain_list')); } return $this-&gt;render('EliophotBackBundle:Domain:new_domain.html.twig', array( 'domain' =&gt; $domain, 'form' =&gt; $newForm-&gt;createView(), )); } </code></pre> <p>This is my DomainType:</p> <pre><code>class DomainType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder -&gt;add('domainName','text', array( 'label' =&gt; 'Nom du domaine' )) -&gt;add('site','entity', array( 'class' =&gt; 'EliophotBackBundle:Site', 'property' =&gt; 'name', 'label' =&gt; 'Sélectionnez un ou plusieurs site(s)', 'multiple' =&gt; true )); } public function getName() { return 'domain'; } ... } </code></pre> <p>and my SiteType:</p> <pre><code>class SiteType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder -&gt;add('name', 'text', array( 'label' =&gt; 'Nom du site', 'required' =&gt; true )) -&gt;add('nameBundle', 'text', array( 'label' =&gt; 'Nom du bundle du site', 'required' =&gt; true )) -&gt;add('numClient', 'integer', array( 'label' =&gt; 'Numéro client du site', 'required' =&gt; true )); } public function getName() { return 'site'; } ... } </code></pre> <p>Site entity : </p> <pre><code>/** * Site * * @ORM\Table() * @ORM\Entity(repositoryClass="Eliophot\BackBundle\Entity\SiteRepository") */ class Site { /** * @var integer * * @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 string * * @ORM\Column(name="name_bundle", type="string", length=255) */ private $nameBundle; /** * @var integer * * @ORM\Column(name="num_client", type="integer") */ private $numClient; /** * @ORM\OneToMany(targetEntity="Domain", mappedBy="site") */ protected $domains; /** * Initialisation */ public function __construct() { $this-&gt;domains = new ArrayCollection(); } /** * Get id * * @return integer */ public function getId() { return $this-&gt;id; } /** * Set name * * @param string $name * @return Site */ public function setName($name) { $this-&gt;name = $name; return $this; } /** * Get name * * @return string */ public function getName() { return $this-&gt;name; } /** * Set nameBundle * * @param $nameBundle * @return $this */ public function setNameBundle($nameBundle) { $this-&gt;nameBundle = $nameBundle; return $this; } /** * Get nameBundle * * @return string */ public function getNameBundle() { return $this-&gt;nameBundle; } /** * Set numClient * * @param integer $numClient * @return Site */ public function setNumClient($numClient) { $this-&gt;numClient = $numClient; return $this; } /** * Get numClient * * @return integer */ public function getNumClient() { return $this-&gt;numClient; } /** * Get domains * * @return ArrayCollection */ public function getDomains() { return $this-&gt;domains; } /** * Set domains * * @param ArrayCollection $domains */ public function setDomains(ArrayCollection $domains) { $this-&gt;domains = $domains; } } </code></pre> <p>Domain entity : </p> <pre><code>/** * Domain * * @ORM\Table() * @ORM\Entity */ class Domain { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * * @ORM\Column(name="domain_name", type="string", length=255) */ private $domainName; /** * @ORM\ManyToOne(targetEntity="Site", inversedBy="domains") * @ORM\JoinColumn(name="site_id", referencedColumnName="id") */ protected $site; /** * Get id * * @return integer */ public function getId() { return $this-&gt;id; } /** * Set domainName * * @param string $domainName * @return Domain */ public function setDomainName($domainName) { $this-&gt;domainName = $domainName; return $this; } /** * Get domainName * * @return string */ public function getDomainName() { return $this-&gt;domainName; } public function getSite() { return $this-&gt;site; } public function setSite($site) { $this-&gt;site = $site; return $this; } } </code></pre> <p>Like the error says, I think Symfony expects a Site Object and not an arrayCollection... when I <code>var_dump</code> the request after the adding, I get this for the site field (in this example I have selected "site de test 1" and "site de test 2") : </p> <pre><code>array(2) { [0]=&gt; string(1) "1" [1]=&gt; string(1) "2" } </code></pre> <p>=> this should be added to the domain table 2 new lines for the domain in question</p> <p>So how can I do this ?</p>