title: Symfony2 FOSUserBundle Overriding Forms
body: <p>I am trying to change the template for the registration form in my application so that I can add some other HTML to it.  Here is the /My/UserBundle/Resources/views/Registration/register.html.twig file:</p>
  
  <pre><code>{% extends "MyUserBundle::layout.html.twig" %}
  
  {% block fos_user_content %}
  &lt;section class="register site-content"&gt;
      &lt;header&gt;
          &lt;h1&gt;{{ 'layout.register'|trans({}, 'FOSUserBundle') }}&lt;/h1&gt;
      &lt;/header&gt;
      &lt;div class="block"&gt;
          {% include "FOSUserBundle:Registration:register_content.html.twig" %}
      &lt;/div&gt;
  &lt;/section&gt;
  {% endblock fos_user_content %}
  </code></pre>
  
  <p>And I have successfully overridden the layout.html.twig:</p>
  
  <pre><code>{% extends 'MyMainBundle::layout.html.twig' %}
  
  {% block title %}{{ site_name }}{% endblock %}
  
  {% block content %}
      {% for key, message in app.session.getFlashes() %}
      &lt;div class="{{ key }}"&gt;
          {{ message|trans({}, 'FOSUserBundle') }}
      &lt;/div&gt;
      {% endfor %}
      {% block fos_user_content %}{% endblock %}
  {% endblock %}
  </code></pre>
  
  <p>as well as form.html.twig:</p>
  
  <pre><code>{% extends 'FOSUserBundle::form.html.twig' %}
  
  {% block field_row %}
      &lt;li class="form_row"&gt;
          {{ form_label(form) }}
          {{ form_errors(form) }}
          {{ form_widget(form) }}
      &lt;/li&gt;
  {% endblock field_row %}
  
  {% block form_widget %}
      &lt;ul {{ block('container_attributes') }}&gt;
          {{ block('field_rows') }}
          {{ form_rest(form) }}
      &lt;/ul&gt;
  {% endblock form_widget %}
  </code></pre>
  
  <p>config parts:</p>
  
  <pre><code># FOS User Configuration
  fos_user:
      db_driver: orm
      firewall_name: main
      user_class: My\UserBundle\Entity\User
      from_email:
        address: %admin_email%
        sender_name: %site_name%
      template:
        engine: twig
        theme: MyUserBundle::form.html.twig
  </code></pre>
  
  <p>I have cleared my cache.</p>
  
  <p>Whenever I go to</p>
  
  <p><a href="http://localhost/register/" rel="nofollow">http://localhost/register/</a></p>
  
  <p>apache just hangs until it times out.</p>
  
  <p>The best I can figure out, is the PHP maximum execution message says it crashes on a twig template in the cache on <strong>line 16</strong>.  That line is <code>function doGetParent(...)</code> The file is:</p>
  
  <pre><code>&lt;?php
  
  /* FOSUserBundle::form.html.twig */
  class __TwigTemplate_9cf68a2af1db50466c556a735bcdeba0 extends Twig_Template
  {
      public function __construct(Twig_Environment $env)
      {
          parent::__construct($env);
  
          $this-&gt;blocks = array(
              'field_row' =&gt; array($this, 'block_field_row'),
              'form_widget' =&gt; array($this, 'block_form_widget'),
          );
      }
  
      protected function doGetParent(array $context)
      {
          return "FOSUserBundle::form.html.twig";
      }
  
      protected function doDisplay(array $context, array $blocks = array())
      {
          $this-&gt;getParent($context)-&gt;display($context, array_merge($this-&gt;blocks, $blocks));
      }
  
      // line 3
      public function block_field_row($context, array $blocks = array())
      {
          // line 4
          echo "    &lt;li class=\"form_row\"&gt;
          ";
          // line 5
          echo $this-&gt;env-&gt;getExtension('form')-&gt;renderLabel($this-&gt;getContext($context, "form"));
          echo "
          ";
          // line 6
          echo $this-&gt;env-&gt;getExtension('form')-&gt;renderErrors($this-&gt;getContext($context, "form"));
          echo "
          ";
          // line 7
          echo $this-&gt;env-&gt;getExtension('form')-&gt;renderWidget($this-&gt;getContext($context, "form"));
          echo "
      &lt;/li&gt;
  ";
      }
  
      // line 11
      public function block_form_widget($context, array $blocks = array())
      {
          // line 12
          echo "    &lt;ul ";
          $this-&gt;displayBlock("container_attributes", $context, $blocks);
          echo "&gt;
          ";
          // line 13
          $this-&gt;displayBlock("field_rows", $context, $blocks);
          echo "
          ";
          // line 14
          echo $this-&gt;env-&gt;getExtension('form')-&gt;renderRest($this-&gt;getContext($context, "form"));
          echo "
      &lt;/ul&gt;
  ";
      }
  
      public function getTemplateName()
      {
          return "FOSUserBundle::form.html.twig";
      }
  
      public function isTraitable()
      {
          return false;
      }
  }
  </code></pre>
  
  <p>It has <strong>also</strong> timed out on <code>\vendor\twig\lib\Twig\Template.php on line 65</code> Which is <code>public function getParent(array $context)</code></p>
  
  <p>So clearly there is some problem with getParent but I don't know what that means or how to fix it.</p>