title: Doctrine Embeddables not working with Symfony forms
body: <p>Has anyone encountered this problem when using doctrine embeddables and symfony forms?</p>
  
  <blockquote>
    <p>if you don't know Doctrine Embeddables are, you can read about it here
    <a href="http://doctrine-orm.readthedocs.org/en/latest/tutorials/embeddables.html" rel="nofollow">http://doctrine-orm.readthedocs.org/en/latest/tutorials/embeddables.html</a></p>
  </blockquote>
  
  <p>When using value object (CategoryType in my case) with symfony form on form submission (during persisting to DB) I get the following warning</p>
  
  <blockquote>
    <p>Warning: ReflectionProperty::getValue() expects parameter 1 to be object, string given</p>
  </blockquote>
  
  <p>This happens because symfony form returns string instead of embeddable object.</p>
  
  <p>The only workaround I have right now is to use <code>mapped =&gt; false</code> on <code>type</code> field and create valid embeddable object inside controller action just before persist. But that's far from "nice" solution and I want to avoid that.</p>
  
  <p>My Entity, Value Object and form (simplified for the sake of question)</p>
  
  <p><em>Foo\BarBundle\Entity\CategoryType</em></p>
  
  <pre><code>&lt;?php
  
  namespace Foo\BarBundle\Entity;
  
  class CategoryType
  {
      /**
       * @var string
       */
      protected $value;
  
      public function __toString()
      {
          return (string) $this-&gt;getValue();
      }
  
      /**
       * @return string
       */
      public function getValue()
      {
          return $this-&gt;value;
      }
  
      /**
       * @param string $value
       *
       * @return $this
       */
      public function setValue($value)
      {
          $this-&gt;value = $value;
  
          return $this;
      }
  }
  </code></pre>
  
  <p><em>Foo\BarBundle\Resources\config\doctrine\CategoryType.orm.yml</em></p>
  
  <pre><code>CategoryType.orm.yml
      Foo\BarBundle\Entity\CategoryType:
          type: embeddable
          fields:
              value:
                  type: string
  </code></pre>
  
  <p><em>Foo\BarBundle\Entity\Category</em></p>
  
  <pre><code>&lt;?php
  
  namespace Foo\BarBundle\Entity;
  
  class Category
  {
      /**
       * @var integer
       */
      protected $id;
      /**
       * @var string
       */
      protected $name;
      /**
       * @var CategoryType
       */
      protected $type;
  
      /**
       * @return int
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * @return \Foo\BarBundle\Entity\CategoryType
       */
      public function getType()
      {
          return $this-&gt;type;
      }
  
      /**
       * @param \Foo\BarBundle\Entity\CategoryType $type
       *
       * @return $this
       */
      public function setType($type)
      {
          $this-&gt;type = $type;
  
          return $this;
      }
  
      /**
       * @return string
       */
      public function __toString()
      {
          return (string) $this-&gt;getName();
      }
  
      /**
       * @return string
       */
      public function getName()
      {
          return $this-&gt;name;
      }
  
      /**
       * @param string $name
       *
       * @return $this
       */
      public function setName($name)
      {
          $this-&gt;name = $name;
  
          return $this;
      }
  }
  </code></pre>
  
  <p><em>Foo\BarBundle\Resources\config\doctrine\Category.orm.yml</em></p>
  
  <pre><code>Foo\BarBundle\Entity\Category:
      type: entity
      fields:
          id:
              type: integer
              id: true
              generator:
                  strategy: AUTO
          name:
              type: string
      embedded:
          type:
              class: CategoryType
  </code></pre>
  
  <p><em>Foo\BarBundle\Form\CategoryType</em></p>
  
  <pre><code>&lt;?php
  
  namespace Foo\BarBundle\Form;
  
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\OptionsResolver\OptionsResolverInterface;
  
  class CategoryType extends AbstractType
  {
      /**
       * @param FormBuilderInterface $builder
       * @param array                $options
       */
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add('name')
              -&gt;add('type')
          ;
      }
  
      /**
       * @param OptionsResolverInterface $resolver
       */
      public function setDefaultOptions(OptionsResolverInterface $resolver)
      {
          $resolver-&gt;setDefaults(
              array(
                  'data_class' =&gt; 'Foo\BarBundle\Entity\Category'
              )
          );
      }
  
      /**
       * @return string
       */
      public function getName()
      {
          return 'category_form';
      }
  }
  </code></pre>