title: Symfony 2, createFormBuilder with ChoiceType on Entity, choice_label is int
body: <p>I have a little problem with Symfony 2 and the form builder.
  I want to create a ChoiceType field based on Doctrine findAll result.</p>
  
  <p>My choices are entities array, but on the choice_label function, the first variable is int ! </p>
  
  <p>I put a little code for explain :</p>
  
  <pre><code>    $categories = $categoryRepository-&gt;findAll();
  
      foreach ($categories as $value) {
          echo "category name : ".$value-&gt;getName()."&lt;br/&gt;";
      }
      /* Result :
          category name : First
          category name : Second
       */        
  
      $form = $this-&gt;createFormBuilder($dance)
              -&gt;add('name', TextType::class, array('label' =&gt; 'Nom de la dance'))
              -&gt;add('description', TextareaType::class, array('label' =&gt; 'Description'))
              -&gt;add('creationDate', DateTimeType::class, array('label' =&gt; 'Date de création'))
              -&gt;add('category', ChoiceType::class, [
                  'choices' =&gt; $categories,
                  'choice_label' =&gt; function($category, $key, $index) {
                      var_dump($category);
                      // Result : int(0) 
                      return $category-&gt;getName();
                      // Exception !
                  },
                  'choice_attr' =&gt; function($category, $key, $index) {
                      return ['class' =&gt; $category-&gt;getId()];
                  },
              ])
              -&gt;add('save', SubmitType::class, array('label' =&gt; 'Sauvegarder'))
              -&gt;getForm();
  </code></pre>
  
  <p>Of course, I have a Fatal error: Call to a member function getName() on integer ...</p>
  
  <p>Someone can help me on this problem ?</p>
  
  <p>Thank you !</p>