title: Symfony2 form validation always returning ERROR: This value should not be blank
body: <p>I have a strange problem using a form in Symfony2. </p>
  
  <p>First i've added the validation as <code>annotations</code> inside the entity class <code>Job</code> here:</p>
  
  <pre><code>class Job
  {
      /**
       * @ORM\Id
       * @ORM\Column(type="integer")
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      protected $id;
  
      /**
       * @ORM\Column(type="string", length=255, nullable=true)
       * @Assert\NotBlank()
       * @Assert\Choice(callback="getTypeValues")
       */
      protected $type;
  
      /**
       * @ORM\Column(type="string", length=255)
       * @Assert\NotBlank()
       */
      protected $company;
  
      /**
       * @ORM\Column(type="string", length=255, nullable=true)
       */
      protected $logo;
  
      /**
       * @Assert\Image()
       */
      protected $file;
  
      /**
       * @ORM\Column(type="string", length=255, nullable=true)
       * @Assert\Url()
       */
      protected $url;
  
      /**
       * @ORM\Column(type="string", length=255)
       * @Assert\NotBlank()
       */
      protected $position;
  
      /**
       * @ORM\Column(type="string", length=255)
       * @Assert\NotBlank()
       */
      protected $location;
  
      /**
       * @ORM\Column(type="text")
       * @Assert\NotBlank()
       */
      protected $description;
  
      /**
       * @ORM\Column(type="text")
       * @Assert\NotBlank()
       */
      protected $how_to_apply;
  
      /**
       * @ORM\Column(type="string", length=255, unique=true)
       * @Assert\NotBlank()
       */
      protected $token;
  
      /**
       * @ORM\Column(type="boolean", nullable=true)
       */
      protected $is_public;
  
      /**
       * @ORM\Column(type="boolean", nullable=true)
       */
      protected $is_activated;
  
      /**
       * @ORM\Column(type="string", length=255)
       * @Assert\NotBlank()
       * @Assert\Email()
       */
      protected $email;
  
      /**
       * @ORM\Column(type="datetime")
       */
      protected $expires_at;
  
      /**
       * @ORM\Column(type="datetime")
       */
      protected $created_at;
  
      /**
       * @ORM\Column(type="datetime", nullable=true)
       */
      protected $updated_at;
  
      /**
       * @ORM\ManyToOne(targetEntity="Category", inversedBy="jobs")
       * @ORM\JoinColumn(name="category_id", referencedColumnName="id")
       * @Assert\NotBlank()
       */
      protected $category;
  }
  </code></pre>
  
  <p>I've created a <code>JobType</code> class and used it inside a form. So i can add jobs.</p>
  
  <pre><code>class JobType extends AbstractType
  {
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add('type', 'choice', array('choices' =&gt; Job::getTypes(), 'expanded' =&gt; true))
              -&gt;add('category')
              -&gt;add('company')
              -&gt;add('file', 'file', array('label' =&gt; 'Company logo', 'required' =&gt; false))
              -&gt;add('url')
              -&gt;add('position')
              -&gt;add('location')
              -&gt;add('description')
              -&gt;add('how_to_apply', null, array('label' =&gt; 'How to apply?'))
              -&gt;add('is_public', null, array('label' =&gt; 'Public?'))
              -&gt;add('email')
          ;
      }
  
      public function setDefaultOptions(OptionsResolverInterface $resolver)
      {
          $resolver-&gt;setDefaults(array(
                  'data_class' =&gt; 'Ibw\JobeetBundle\Entity\Job',
              ));
      }
  
      public function getName()
      {
          return 'job';
      }
  }
  </code></pre>
  
  <p>Here's my controller:</p>
  
  <pre><code>public function createAction(Request $request)
  {
      $entity = new Job();
      $form = $this-&gt;createForm(new JobType(), $entity);
      $form-&gt;handleRequest($request);
  
      if($form-&gt;isValid())
      {
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $em-&gt;persist($entity);
          $em-&gt;flush();
  
          return $this-&gt;redirect($this-&gt;generateUrl('ibw_job_preview', array(
                  'company'   =&gt; $entity-&gt;getCompanySlug(),
                  'location'  =&gt; $entity-&gt;getLocationSlug(),
                  'position'  =&gt; $entity-&gt;getPositionSlug(),
                  'token'     =&gt; $entity-&gt;getToken(),
              )));
      } else {
          return new Response(var_dump($form-&gt;getErrorsAsString()));
  //            return new Response($form-&gt;getErrorsAsString());
  //          return $this-&gt;render('IbwJobeetBundle:Job:new.html.twig', array(
  //                  'form' =&gt; $form-&gt;createView(),
  //              ));
      }
  }
  </code></pre>
  
  <p>Now when i do <code>var_dump($form-&gt;getErrorsAsString())</code> I get:</p>
  
  <pre><code>string 'ERROR: This value should not be blank.
  type:
      0:
          No errors
      1:
          No errors
      2:
          No errors
  category:
      No errors
  company:
      No errors
  file:
      No errors
  url:
      No errors
  position:
      No errors
  location:
      No errors
  description:
      No errors
  how_to_apply:
      No errors
  is_public:
      No errors
  email:
      No errors
  ' (length=355)
  </code></pre>
  
  <p>Or when i do <code>var_dump($form-&gt;getErrors())</code> I get:</p>
  
  <pre><code>array (size=1)
    0 =&gt; 
      object(Symfony\Component\Form\FormError)[614]
        private 'message' =&gt; string 'This value should not be blank.' (length=31)
        protected 'messageTemplate' =&gt; string 'This value should not be blank.' (length=31)
        protected 'messageParameters' =&gt; 
          array (size=0)
            empty
        protected 'messagePluralization' =&gt; null
  </code></pre>
  
  <p>I have no idea what generates this <code>ERROR: This value should not be blank.</code> error. I'm having hard times figuring it out. Any help would be greatly appreciated.</p>