title: Symfony 2 - how to pass data to formBuilder?
body: <p>I'm using entity choice list in my form. I want to use only specific entities (in example: only groups that user belongs to)
  So, in controller, I'm getting these groups, and trying to pass them into <code>formBuider</code>.</p>
  
  <p>Controller:</p>
  
  <pre><code>/.../
  $groups = $em-&gt;getRepository('VendorMyBundle:Group')-&gt;getUserGroups($user);
  $form = $this-&gt;createForm(new Message($groups), $message);
  /.../
  </code></pre>
  
  <p>so, what now? how to use it in formBuilder?
  how to change this line to use passed array of groups?</p>
  
  <pre><code>-&gt;add('group','entity',array('class' =&gt; 'Vendor\MyBundle\Entity\Group', 'label'=&gt;'Group:'))
  </code></pre>
  
  <p>or in the other way:</p>
  
  <pre><code>class MessageType
  {
  /.../
    public function buildForm(FormBuilder $builder, array $options)
    {
      $builder
        -&gt;add('group','entity',
          array(
            'class' =&gt; 'Vendor\MyBundle\Entity\Group',
            'property' =&gt; 'name',
            'query_builder' =&gt; function ($repository) {
              $qb = $repository-&gt;createQueryBuilder('group');
              $qb-&gt;add('where', 'group.administrator = :user');
              $qb-&gt;setParameter('user', $user-&gt;getId());
              return $qb;
            },
            'label' =&gt; 'Group'
          )
        )
        // Continue adding fields
      ;
    }
  /.../
  }
  </code></pre>
  
  <p>so how can i get object $user to use in form builder? ($user represent current logged user)</p>