title: Symfony2 change validation group based on field value
body: <p>I have controller action like this:</p>
  
  <pre><code>public function createAction()
  {
      $entity  = new Client();
  
      $request = $this-&gt;getRequest();
      $form    = $this-&gt;createForm(new ClientType(), $entity);
      $form-&gt;bindRequest($request);
  
      if ($form-&gt;isValid()) {
          $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
          $em-&gt;persist($entity);
          $em-&gt;flush();
  
          return $this-&gt;redirect($this-&gt;generateUrl('client_show', array('id' =&gt; $entity-&gt;getId())));
  
      }
  
      return array(
          'entity' =&gt; $entity,
          'form'   =&gt; $form-&gt;createView()
      );
  }
  </code></pre>
  
  <p>The underlying <code>Client</code> Entity has a field <code>type</code> witch can take values <code>[0, 1]</code> now, I have defined the 2 validation groups for <code>Client</code> entity: <code>person</code> and <code>company</code>.</p>
  
  <p>How can I change/choose validation group based on user entered value into <code>type</code> field?</p>