title: UnexpectedTypeException in Symfony2 forms
body: <p>I have an entity that looks like this:</p>
  
  <pre><code>class Person
  {
      protected $name;
  
      public function setName($name)
      {
          $this-&gt;name = $name;
      }
  
      public function getName()
      {
          if(empty($this-&gt;name)) {
              return '';
          }
          return $this-&gt;name;
      }
  }
  </code></pre>
  
  <p>With a normal <code>PersonType</code> form:</p>
  
  <pre><code>class PersonType
  {
       public function buildForm(FormBuilderInterface $builder, ...)
           $build-&gt;add('name', 'text');
       }
  }
  </code></pre>
  
  <p>When I try to build the form in the controller via Symfony's</p>
  
  <p><code>$this-&gt;createForm(new PersonType(), new Person());</code></p>
  
  <p>I get the error:</p>
  
  <p><code>Expected argument of type "object, array or empty", "string" given in Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php at line 49</code></p>
  
  <p>I have this for several fields, I figure Symfony2 does not regard an empty string <code>''</code> as empty.
  So what can I do? Create a model transformer for every field in my form?... 
  That would seem a little too much. Any suggestions? Thanks in advance!</p>
  
  <p>For the record if I just return the null value when it's not set such as <code>return $this-&gt;name;</code> and without checking if <code>$this-&gt;name</code> is empty error goes away and the form is properly rendered as expected.</p>