title: How to get user ID (FOSUserBundle) in form builder in Symfony2?
body: <p>I'm quite new here, be patient, please.</p>
  
  <p>I'm trying to make notice board project in Symfony2 using FOSUserBundle.
  I try to get logged user id to put it into form created with form builder (and then to MySQL database).
  One of attempts  is:</p>
  
  <pre><code>public function createNoticeAction(Request $request)
      {
          $notice = new Notice();
          $form = $this-&gt;createFormBuilder($notice)
              -&gt;add("content", "text")
              -&gt;add("user_id","entity",
                  array("class"=&gt;"FOS/UserBundle/FOSUserBundle:", "choice_label"=&gt;"id"))
              -&gt;add("isActive", "true")
              -&gt;add("category", "entity",
                  array("class" =&gt; "AppBundle:Category", "choice_label" =&gt; "name"))
              -&gt;add("save", "submit", array("label" =&gt; "Save"))
              -&gt;getForm();
          $form-&gt;handleRequest($request);
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $em-&gt;persist($notice);
          $em-&gt;flush();
  
          return $this-&gt;redirectToRoute('app_user_showuserpage');
      }
  </code></pre>
  
  <p>I tried many solutions again and again and  I get some error.</p>