title: Symfony 2 Add CSRF Token when using a form without a class
body: <p>Firstly I'm a complete noobie with Symfony 2. The question sounds simple, if I try and put some context into why and how I need this it will start to get confusing. </p>
  
  <p>In essence I've created a form, which I manually process, validate and insert using Doctrine etc. I am manually creating the form within a controller action (it's built dynamically from retrieved values from another object). I'm assuming there maybe better ways to do this, but as I'm new to Symfony and days of trawling the net, I can't see any solutions to what I need to do.</p>
  
  <p>Therefore I'm not simply building a form against a class/entity etc and so I will manually need to add a CSRF token or some kind of protection.</p>
  
  <p>In normal circumstances you would create the FormType and configure default options to have csrf_protection. Then a simple case of:</p>
  
  <pre><code>{{ form_widget(form._token) }}
  </code></pre>
  
  <p>and the csrf token is there.</p>
  
  <p>As I'm dynamically building the form I am not sure how I can manually create a csrf token for my form. Has anyone had any experience of creating forms without a class and adding csrf protection?</p>
  
  <p>Kind regards
  Paul Pounder</p>