title: Symfony Enum Type with formType
body: <p>I have a symfony entity that have an enum type field  and I want to generate a form type for it.
  I want to know the right way to do that.</p>
  
  <p>this is my entity : </p>
  
  <pre><code>&lt;?php
  
  namespace EvalBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * SessionEvaluation
   *
   * @ORM\Table(name="session_evaluation")
   * @ORM\Entity(repositoryClass="EvalBundle\Repository\SessionEvaluationRepository")
   */
  class SessionEvaluation
  {
      /**
       * @var int
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @var string
       *
       * @ORM\Column(name="name", type="string", length=255, unique=true)
       */
      private $name;
  
      /**
       * @var \DateTime
       *
       * @ORM\Column(name="startDate", type="datetime")
       */
      private $startDate;
  
      /**
       * @var \DateTime
       *
       * @ORM\Column(name="endDate", type="datetime")
       */
      private $endDate;
  
      /**
       * @var string
       *
       * @ORM\Column(name="type", type="string", columnDefinition="enum('annual', 'intermediate')")
       */
      private $type;
  
      /**
       * One SessionEvaluation has Many PerformanceEvaluation.
       * @ORM\OneToMany(targetEntity="PerformanceEvaluation", mappedBy="sessionEvaluation")
       */
      private $performanceEvaluations;
  
      /**
       * One SessionEvaluation has Many Evaluation.
       * @ORM\OneToMany(targetEntity="Evaluation", mappedBy="sessionEvaluation")
       */
      private $evaluations;
  
      /**
       * Get id
       *
       * @return int
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set name
       *
       * @param string $name
       *
       * @return SessionEvaluation
       */
      public function setName($name)
      {
          $this-&gt;name = $name;
  
          return $this;
      }
  
      /**
       * Get name
       *
       * @return string
       */
      public function getName()
      {
          return $this-&gt;name;
      }
  
      /**
       * Set startDate
       *
       * @param \DateTime $startDate
       *
       * @return SessionEvaluation
       */
      public function setStartDate($startDate)
      {
          $this-&gt;startDate = $startDate;
  
          return $this;
      }
  
      /**
       * Get startDate
       *
       * @return \DateTime
       */
      public function getStartDate()
      {
          return $this-&gt;startDate;
      }
  
      /**
       * Set endDate
       *
       * @param \DateTime $endDate
       *
       * @return SessionEvaluation
       */
      public function setEndDate($endDate)
      {
          $this-&gt;endDate = $endDate;
  
          return $this;
      }
  
      /**
       * Get endDate
       *
       * @return \DateTime
       */
      public function getEndDate()
      {
          return $this-&gt;endDate;
      }
  
      /**
       * Set type
       *
       * @param string $type
       *
       * @return SessionEvaluation
       */
      public function setType($type)
      {
          $this-&gt;type = $type;
  
          return $this;
      }
  
      /**
       * Get type
       *
       * @return string
       */
      public function getType()
      {
          return $this-&gt;type;
      }
  
      public function __toString() {
          return $this-&gt;name;
      }
  }
  </code></pre>
  
  <p>and here is the formType : </p>
  
  <pre><code>&lt;?php
  
  namespace EvalBundle\Form;
  
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  use Symfony\Component\Form\Extension\Core\Type\DateType;
  use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  use Symfony\Component\Form\Extension\Core\Type\TextType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\OptionsResolver\OptionsResolver;
  
  class SessionEvaluationType extends AbstractType
  {
      /**
       * {@inheritdoc}
       */
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder-&gt;add('Name', TextType::class, array(
              'attr'=&gt; array('class'=&gt;'form-control')
          ))
                  -&gt;add('startDate', DateType::class, array(
                      'format' =&gt; 'yyyy MM dd'
                  ))
                  -&gt;add('endDate')
                  -&gt;add('type', ChoiceType::class, array(
                      'choices' =&gt; array(
                          'Annuel' =&gt; true,
                          'Itérmidaire' =&gt; false,
                      ),
                      'attr' =&gt; array('class' =&gt; 'dropdown')
  
                  ))
              -&gt;add('Lancer', SubmitType::class, array(
                  'attr' =&gt; array('class' =&gt; 'btn btn-primary')));
  
      }
  
      /**
       * {@inheritdoc}
       */
      public function configureOptions(OptionsResolver $resolver)
      {
          $resolver-&gt;setDefaults(array(
              'data_class' =&gt; 'EvalBundle\Entity\SessionEvaluation'
          ));
      }
  
      /**
       * {@inheritdoc}
       */
      public function getBlockPrefix()
      {
          return 'evalbundle_sessionevaluation';
      }
  
  
  }
  </code></pre>
  
  <blockquote>
    <p>the field with enum type is : type</p>
  </blockquote>
  
  <p>I've defined it as choiceType in the form, is this a good way to do it for save the entity instance in the database after submit the form ?</p>