title: Twig form builder rendering time
body: <p>I'm using Twig to build form like this :</p>
  
  <p><strong>Class :</strong></p>
  
  <pre><code>public function buildForm(FormBuilderInterface $builder, array $options)
  {
      $builder
          -&gt;add('name', 'text', array(
              'constraints' =&gt; array(new Assert\NotBlank(), new Assert\Length(array('min' =&gt; 5)))
          ))
          -&gt;add('mail', 'email', array(
              'constraints' =&gt; array(new Assert\NotBlank(), new Assert\Email())
          ));
  }
  </code></pre>
  
  <p><strong>Twig :</strong></p>
  
  <pre><code>&lt;div class="col-xs-12 col-less-padding"&gt;
      {{ form_start(contactForm, { 'attr': {'class': 'form-horizontal pull-left'} }) }}
          &lt;div class="form-group"&gt;
              {{ form_label(contactForm.name, null, { 'label_attr':  {
                  'class': 'col-sm-4 control-label'
              }}) }}
              &lt;div class="col-sm-6"&gt;
                  {{ form_widget(contactForm.name, { 'attr':  {
                      'class': 'form-control'
                  }}) }}
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="form-group"&gt;
              {{ form_label(contactForm.mail, null, { 'label_attr':  {
                  'class': 'col-sm-4 control-label'
              }}) }}
              &lt;div class="col-sm-6"&gt;
                  {{ form_widget(contactForm.mail, { 'attr':  {
                      'class': 'form-control'
                  }}) }}
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="form-group"&gt;
              &lt;div class="col-sm-offset-4 col-sm-3"&gt;
                  &lt;input type="submit" class="btn btn-primary" value="Send"&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      {{ form_end(contactForm) }}
  &lt;/div&gt;
  </code></pre>
  
  <p>But it looks like it really impacts on the rendering time of my pages. For exemple, static pages have a total rendering time of 350-400ms but when I click on this contact page, the total rendering time is 800-850ms.</p>
  
  <p>I'm in dev environment (so I'm not using Twig cache option or gzip compression) and the debug toolbar says that controller took 652ms and Twig templates 387ms. <strong>Is that a correct time?</strong></p>
  
  <p><strong>Debug stats screenshot : <a href="http://i.imgur.com/FTfsoKX.png" rel="nofollow">here</a> and <a href="http://i.imgur.com/X2qmw8l.png" rel="nofollow">here</a></strong></p>
  
  <p>I have only one controller file HomeController.php for the whole site (it's a small site so there is only 9 functions in it) - <strong>is that a problem?</strong> ; here is the function concerning the contact action :</p>
  
  <p><strong>HomeController :</strong></p>
  
  <pre><code>/* 8 others functions */
  
  public function contactAction(Request $request, Application $app) {
      $book_id = $app['dao.home']-&gt;returnBookId();
      $contactForm = $app['form.factory']-&gt;create(new ContactType());
      $contactForm-&gt;handleRequest($request);
  
      if ($contactForm-&gt;isSubmitted() &amp;&amp; $contactForm-&gt;isValid()) {
          $formData = $contactForm-&gt;getData();
          $msg = 'New message from'.$formData['name'].'('.$formData['mail'].') &lt;br&gt;&lt;br&gt;';
          $msg .= 'Content : '.$formData['content'].'';
          mail("mail@gmail.com","New message",$msg);
          $app['session']-&gt;getFlashBag()-&gt;add('success', 'Your message was sent successfully.');
      }
  
      return $app['twig']-&gt;render('contact.html.twig', array(
          'active_page' =&gt; 'contact',
          'book_id' =&gt; $book_id,
          'contactForm' =&gt; $contactForm-&gt;createView()));
  }
  </code></pre>
  
  <p>So <strong>is using the form builder a good way to build form?</strong> Or <strong>maybe should I build the form myself with two html inputs and a submit button?</strong></p>
  
  <p>Also, <strong>when is it advisable to use the form builder rather than create the inputs myself in the view?</strong></p>