title: Symfony2 choice field not working
body: <p>I asked a question here <a href="https://stackoverflow.com/questions/16441771/how-to-use-repository-custom-functions-in-a-formtype">How to use Repository custom functions in a FormType</a> but nobody anwsered, so i did a little digging and advanced a little but i still get this error:</p>
  
  <pre><code>Notice: Object of class Proxies\__CG__\Kpr\CentarZdravljaBundle\Entity\Category 
  could not be converted to int in /home/kprhr/public_html/CZ_Symfony/vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php line 457 
  </code></pre>
  
  <p>Now this is how my CategoryType looks like:</p>
  
  <pre><code>&lt;?php
  
  namespace Kpr\CentarZdravljaBundle\Form\Type;
  
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\OptionsResolver\OptionsResolverInterface;
  use Symfony\Bridge\Doctrine\RegistryInterface;
  
  class CategoryType extends AbstractType
  {
      private $doctrine;
  
      public function __construct(RegistryInterface $doctrine)
      {
          $this-&gt;doctrine = $doctrine;
      }
      public function setDefaultOptions(OptionsResolverInterface $resolver)
      {
          $resolver-&gt;setDefaults(array(
              'data_class' =&gt; 'Kpr\CentarZdravljaBundle\Entity\Category',
              'catID' =&gt; null,
          ));
      }
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $someId = $builder-&gt;getData()-&gt;getId();
          $param = ($someId) ? $someId : 0;
          $catID = $options['catID'];
          $builder-&gt;add('name', 'text', array('attr'   =&gt;  array('class' =&gt; 'span6')));
          $builder-&gt;add('file', 'file', array('image_path' =&gt; 'webPath', 'required' =&gt; false));
          $builder-&gt;add('parent', 'choice', array(
                      'choices' =&gt; $this-&gt;getAllChildren($catID),
                      'required' =&gt; false,
                      'attr'   =&gt;  array('data-placeholder' =&gt; '--Izaberite Opciju--'),
                      ));
          $builder-&gt;add('tags', 'tag_selector', array(
              'required'  =&gt; false,
          ));
          $builder-&gt;add('status', 'choice', array(
              'choices'   =&gt; array('1' =&gt; 'Aktivna', '0' =&gt; 'Neaktivna'),
              'required'  =&gt; true,
          ));
          $builder-&gt;add('queue', 'text', array('attr'   =&gt;  array('class' =&gt; 'span3')));
      }
      private function getAllChildren($catID)
      {
          $choices = array();
          $children = $this-&gt;doctrine-&gt;getRepository('KprCentarZdravljaBundle:Category')-&gt;findByParenting($catID);
  
          foreach ($children as $child) {
              $choices[$child-&gt;getId()] = $child-&gt;getName();
          }
  
          return $choices;
      }
  
      public function getName()
      {
          return 'category';
      }
  
  }
  </code></pre>
  
  <p>I am accessing the CategoryRepository function findByParenting($parent) from the CategoryType and I am getting the array populated with accurate data back from the function getAllChildren($catID) but the error is there, i think that Symfony framework is expecting an entity field instead of choice field, but dont know how to fix it.
  I also changet the formCreate call in the controller giving $this->getDoctrine() as an argument to CategoryType():</p>
  
  <pre><code>$form = $this-&gt;createForm(new CategoryType($this-&gt;getDoctrine()), $cat, array('catID' =&gt; $id));
  </code></pre>