title: Symfony2: Pass Parameter to Form entity object for query_builder
body: <p>In My form i use this code</p>
  
  <pre><code>$form-&gt;add('user', 'entity', 
          array(
                  'label' =&gt; 'User Name',
                  'class' =&gt; 'DotArtBundle:User',
                  'property' =&gt; 'name',
                  'query_builder' =&gt; function(EntityRepository $er){
                                  return $er-&gt;createQueryBuilder('u')-&gt;where('u.type = 1');
                              }
              )
      );
  </code></pre>
  
  <p>I want </p>
  
  <p>if user role is <code>ROLE_ADMIN</code> run this code and show all user (This code do this)</p>
  
  <p>if user role is <code>ROLE_USER</code> this code only show authenticated user in list</p>
  
  <pre><code>  'query_builder' =&gt; function(EntityRepository $er){
           return $er-&gt;createQueryBuilder('u')-&gt;where('u.type = 1 and u.id = ' . $this-&gt;getUser()-&gt;getId());
      }
  </code></pre>
  
  <p><strong>Error</strong>
  I check this code and return error:</p>
  
  <pre><code> $where  = 'u.id = '.$userid;
   $form = $this-&gt;createFormBuilder($poduct)
                -&gt;add('user', 'entity', 
                        array(
                          'label' =&gt; 'نانم کاربری',
                          'class' =&gt; 'DotArtBundle:User',
                          'property' =&gt; 'name',
                          'query_builder' =&gt; function(EntityRepository $er){
                                                 return $er-&gt;createQueryBuilder('u')-&gt;where($where);
                                                  }
                                  )
                          )
  Notice: Undefined variable: where in C:\xampp\htdocs\ArtGirl\src\Dot\ArtBundle\Controller\ProductController.php line 38
  </code></pre>