title: Symfony2 Forms & Doctrine: Persist EmailType with multiple addresses into simple_array
body: <p>It looks like there is no <em>direct</em> way to save the outcome of <code>&lt;input type="email" multiple&gt;</code> into Doctrine's <code>simple_array</code> field, through Symfony 2 forms.</p>
  
  <p>Details:  </p>
  
  <ul>
  <li>My entity is of type <code>simple_array</code>: <a href="http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html#simple-array" rel="nofollow">http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html#simple-array</a></li>
  <li>The FormType has<br>
  <code>$builder-&gt;add('emails', EmailType::class, array('attr'=&gt;array('multiple'=&gt;'multiple')));</code><br>
  <a href="http://symfony.com/doc/current/reference/forms/types/email.html" rel="nofollow">http://symfony.com/doc/current/reference/forms/types/email.html</a></li>
  <li>Which renders (as expected):<br>
  <code>&lt;input type="email" multiple="multiple"&gt;</code><br>
  <a href="https://html.spec.whatwg.org/#e-mail-state-(type=email)" rel="nofollow">https://html.spec.whatwg.org/#e-mail-state-(type=email)</a></li>
  </ul>
  
  <p>Now, when I enter two email addresses in the form (comma-separated, as expected by HTML5), the entity receives a comma-separated <em>string</em>.</p>
  
  <p>However, when persisting into the <code>simple_array</code> field, Doctrine expects an <em>array</em>, onto which it calls <code>implode()</code>.</p>
  
  <p>So the error message I get is: <code>Warning: implode(): Invalid arguments passed</code></p>
  
  <p>Reason: Symfony doesn't explode the comma-separated string into an array, before handing it over to Doctrine.</p>
  
  <p>Solution: Do it manually:<br>
  <code>$entity-&gt;setEmails(explode(',', $entity-&gt;getEmails()));</code></p>
  
  <p>So finally my question is: Is there an easier way for this?</p>