title: Validating dynamically loaded choices in Symfony 2
body: <p>I have a choice field type named *sub_choice* in my form whose choices will be dynamically loaded through AJAX depending on the selected value of the parent choice field, named *parent_choice*. Loading the choices works perfectly but I'm encountering a problem when validating the value of the sub_choice upon submission. It gives a "This value is not valid" validation error since the submitted value is not in the choices of the sub_choice field when it was built. So is there a way I can properly validate the submitted value of the sub_choice field? Below is the code for building my form. I'm using Symfony 2.1.</p>
  
  <pre><code>public function buildForm(FormBuilderInterface $builder, array $options)
  {
      $builder-&gt;add('parent_choice', 'entity', array(
                      'label' =&gt; 'Parent Choice',
                      'class' =&gt; 'Acme\TestBundle\Entity\ParentChoice'
      ));
  
      $builder-&gt;add('sub_choice', 'choice', array(
                      'label' =&gt; 'Sub Choice',
                      'choices' =&gt; array(),
                      'virtual' =&gt; true
      ));
  }
  </code></pre>