title: symfony2 entity field type error
body: <p>I haven't found any solid example on how to do this.</p>
  
  <p>I have my entity Shield, which can have more than 1 ShieldTypes. What I want to do is, create a form that creates a new Shield with different Shieldtypes.</p>
  
  <p>This is my code, I honestly don't know where is my error:</p>
  
  <p>Error is:</p>
  
  <pre><code>Entities passed to the choice field must be managed
  500 Internal Server Error - FormException 
  </code></pre>
  
  <p>Armory\SearchBundle\Entity\Shield.php</p>
  
  <pre><code>namespace Armory\SearchBundle\Entity;
  use Doctrine\ORM\Mapping as ORM;
  /**
   * Armory\SearchBundle\Entity\Shield
   *
   * @ORM\Table(name="shield")
   * @ORM\Entity
   */
  class Shield
  {
      /**
       * @var integer $id
       * @ORM\Column(name="id", type="integer", nullable=false)
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="IDENTITY")
       */
      private $id;
      /**
       * @var string $name
       * @ORM\Column(name="name", type="string", length=45, nullable=false)
       */
      private $name;
      /**
       * @var integer $defense
       * @ORM\Column(name="defense", type="integer", nullable=false)
       */
      private $defense;
  
      /**
       * @var boolean $active
       * @ORM\Column(name="active", type="boolean", nullable=false)
       */
      private $active;
  
      /**
       * @ORM\ManyToMany(targetEntity="ShieldTypes")
       * @ORM\JoinTable(name="i_orbs_type",
       *     joinColumns={@ORM\JoinColumn(name="id_orb", referencedColumnName="id")},
       *     inverseJoinColumns={@ORM\JoinColumn(name="id_type", referencedColumnName="id")}
       * )
       * @var ArrayCollection $types
       */
      protected $types;
      public function __construct(){
          $this-&gt;types = new \Doctrine\Common\Collections\ArrayCollection();
      }
      public function getTypes(){
          return $this-&gt;types;
      }
      public function getId()
      {
          return $this-&gt;id;
      }
      public function setName($name)
      {
          $this-&gt;name = $name;
      }
      public function getName()
      {
          return $this-&gt;name;
      }
      public function setDefense($defense)
      {
          $this-&gt;defense = $defense;
      }
      public function getDefense()
      {
          return $this-&gt;defense;
      }
      public function setActive($active)
      {
          $this-&gt;active = $active;
      }
      public function getActive()
      {
          return (bool)$this-&gt;active;
      }
  }
  </code></pre>
  
  <p>Armory\SearchBundle\Form\ShieldType.php:</p>
  
  <pre><code>namespace Armory\SearchBundle\Form;
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilder;
  class ShieldType extends AbstractType{
  
  public function buildForm(FormBuilder $builder, array $options){
      $builder-&gt;add('name','text');
      $builder-&gt;add('defense','integer');
      $builder-&gt;add('active','checkbox');
  
      $builder-&gt;add('types','entity',
              array(
                  'class'=&gt;'Armory\SearchBundle\Entity\ShieldTypes', 
                  'query_builder'=&gt; function($repository){ 
                              return $repository-&gt;createQueryBuilder('t')-&gt;orderBy('t.id', 'ASC');
                      },
                  'property'=&gt;'name', )
              );
  }
  
  public function getName(){
      return 'shield';
  }
  
  public function getDefaultOptions(array $options){
      return array('data_class'=&gt;'Armory\\SearchBundle\\Entity\\Shield');
  }
  }
  </code></pre>
  
  <p>Armory\SearchBundle\Entity\ShieldTypes.php</p>
  
  <pre><code>namespace Armory\SearchBundle\Entity;
  use Doctrine\ORM\Mapping as ORM;
  /**
   * SOA\CRMBundle\Entity\ShieldTypes
   *
   * @ORM\Table(name="orbs_type")
   * @ORM\Entity
   */
  class ShieldTypes
  {
      /**
       * @var integer $id
       *
       * @ORM\Column(name="id", type="integer", nullable=false)
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="IDENTITY")
       */
      private $id;
      /**
       * @var string $name
       *
       * @ORM\Column(name="name", type="string", length=45, nullable=false)
       */
      private $name;
      /**
       * @var string $title
       *
       * @ORM\Column(name="title", type="string", length=45, nullable=false)
       */
      private $title;
      public function getId()
      {
          return $this-&gt;id;
      }
      public function setName($name)
      {
          $this-&gt;name = $name;
      }
      public function getName()
      {
          return $this-&gt;name;
      }
      public function setTitle($title)
      {
          $this-&gt;title = $title;
      }
      public function getTitle()
      {
          return $this-&gt;title;
      }   
  }
  </code></pre>
  
  <p>It can be a little confusing but:</p>
  
  <pre><code>Shield entity (database)
  ShieldTypes entity (database)
  ShieldType form (abstracttype)
  </code></pre>
  
  <p>Thank you...</p>