Liipimaginebundle: Unable to find template "LiipImagineBundle:Form:form_div_layout.html.twig"

Created on 7 Dec 2017  路  4Comments  路  Source: liip/LiipImagineBundle

| Q | A
| --- | ---
| Bug Report? | yes
| Feature Request? | no
| BC Break Report? | no
| RFC? | no
| Imagine Bundle Version | 1.9.1

So simply I've instaslled latest symfony 3.4. It's empty installation on php 7.1. And I've installed this bundle. Right after installation, just after adding it to the kernel I get this error:

Unable to find template "LiipImagineBundle:Form:form_div_layout.html.twig" (looked into: /path_to_project/app/Resources/views, /path_to_project/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form).

Error points to form with file field:

{{ form_start(form, { 'attr': { 'novalidate': 'novalidate' } }) }}

If I remove the form, everything is back to normal. When I removed this template from registration, everything was back to normal. Then I tried something else and I moved bundle in kernel BEFORE new Symfony\Bundle\TwigBundle\TwigBundle(),. And now it's working.

Most helpful comment

The problem exists only if you add new Liip\ImagineBundle\LiipImagineBundle() after Symfony\Bundle\TwigBundle\TwigBundle(). The installation guide should highlight the fact that the bundle should be loaded after twig.

All 4 comments

Same problem for me, I tested your solution

I moved bundle in kernel BEFORE new Symfony\Bundle\TwigBundle\TwigBundle()

And it works, however the problem applied to my other bundles with the syntax

return $this->render('AcmeBundle:Folder:form.html.twig', array( 'form' => $form->createView() ));

If i replace by

return $this->render('@Acme/Folder/form.html.twig', array( 'form' => $form->createView() ));

It works also.

Changing https://github.com/liip/LiipImagineBundle/blob/1.0/DependencyInjection/LiipImagineExtension.php line 101 from

$resources[] = 'LiipImagineBundle:Form:form_div_layout.html.twig';

to

$resources[] = '@LiipImagine/Form/form_div_layout.html.twig';

Fixed also the problem without moving the bundles order in AppKernel.

I don't have this problem with SF 3.3, only with SF 3.4, so maybe it is not related to LiipImagineBundle ?

Symfony docs https://symfony.com/doc/3.4/templating/namespaced_paths.html says the syntax with semi-colon is no longer recommended

The problem exists only if you add new Liip\ImagineBundle\LiipImagineBundle() after Symfony\Bundle\TwigBundle\TwigBundle(). The installation guide should highlight the fact that the bundle should be loaded after twig.

This issue is fixed in the 2.0 branch, just change it in your composer.json file "liip/imagine-bundle": "^2.0@dev"

But it's a dev branch so you may not want to add this to a production environment.

2.0 is not working for symfony < 4

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robfrawley picture robfrawley  路  4Comments

danaki picture danaki  路  6Comments

fueguino84 picture fueguino84  路  3Comments

fabianbartsch picture fabianbartsch  路  3Comments

Aerendir picture Aerendir  路  3Comments