title: passing data from controller to Type symfony2
body: <p>if i show a field of type "entity" in my form, and i want to filter this entity type based on a argument I pass from the controller, how do i do that.. ?</p>
  
  <pre><code>//PlumeOptionsType.php
  public function buildForm(FormBuilder $builder, array $options)
  {
      $builder-&gt;add('framePlume', 'entity', array(
          'class' =&gt; 'DessinPlumeBundle:PhysicalPlume',
          'query_builder' =&gt; function(EntityRepository $er) {
                                  return $er-&gt;createQueryBuilder('pp')
                                      -&gt;where("pp.profile = :profile")
                                      -&gt;orderBy('pp.index', 'ASC')
                                      -&gt;setParameter('profile', ????)
                                  ;
                              },
  
      ));
  }
  
  public function getName()
  {
      return 'plumeOptions';
  }
  
  public function getDefaultOptions(array $options)
  {
      return array(
              'data_class'      =&gt; 'Dessin\PlumeBundle\Entity\PlumeOptions',
              'csrf_protection' =&gt; true,
              'csrf_field_name' =&gt; '_token',
              // a unique key to help generate the secret token
              'intention'       =&gt; 'plumeOptions_item',
      );
  }
  }
  </code></pre>
  
  <p>and inside the controller, i create the form :</p>
  
  <pre><code>i have that argument that i need to pass in my action code:
  $profile_id = $this-&gt;getRequest()-&gt;getSession()-&gt;get('profile_id');
  ...
  and then i create my form like this
  $form = $this-&gt;createForm(new PlumeOptionsType(), $plumeOptions);
  </code></pre>
  
  <p>the $plumeOptions is just a class to persist. But it has a one-to-one relationship with another class called PhysicalPlume. Now, when i want to display the 'framePlume' in my code, i want to show a filtered PhysicalPlume entity.</p>