Search code examples
phpsymfonytwigsymfony-3.2

Unable to find template Symfony 3


After some template renaming mystery happens – twig looking for wrong template and did not find it even it really exists:

Unable to find template "form/bootstrap_3_horizontal_layout.html.twig" (looked into: /home/travel/www/gai/app/Resources/views, /home/travel/www/gai/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form).

Symfony debugger points to error at line 31:

  30      {% form_theme edit_form 'form/bootstrap_3_horizontal_numbers.html.twig' %}
  31      {{ form_start(edit_form) }}
  32      <div class="box-body">
  33          {{ form_widget(edit_form) }}
  34      </div>

However as you may notice it fails to find theme *layout.html.twig not the *numbers.html.twig.

You may say it may be some issue with caching? It may be but I cleared it as well as know how to: php bin/console cache:clear, rm -rf app/cache. Will be appreciate ideas about what I'm missing. Thank you.

EDIT:

Here is output of ls -la app/Resources/views/form/

drwxrwxr-x  2 travel travel 4096 Geg  3 08:56 .
drwxrwxr-x 11 travel travel 4096 Bal 23 23:47 ..
-rw-rw-r--  1 travel travel 2399 Geg  3 08:56 bootstrap_3_horizontal_layout.html
-rw-rw-r--  1 travel travel 2577 Geg  3 00:22 bootstrap_3_horizontal_numbers.html.twig
-rw-rw-r--  1 travel travel 9668 Kov 19 10:20 bootstrap_3_layout.html.twig

Solution

  • After reading the output of ls -la the most obviously reason should be that your *layout.html file is missing the .twig ending in the filename.

    Error message:

    Unable to find template "form/bootstrap_3_horizontal_layout.html.twig"

    Filename:

    form/bootstrap_3_horizontal_layout.html

    Change Filename to:

    form/bootstrap_3_horizontal_layout.html.twig