Reputation: 3194
My experience with Symfony frontend development is definitely limited. According to http://symfony.com/blog/new-in-symfony-2-6-bootstrap-form-theme I read that adding bootstrap_3_layout.html.twig
as a twig form resource I should be able to essentially add Bootstrap themes to my form.
I presume I need to add some CSS files somewhere, maybe, but I haven't even got that far yet.
My problem is that after setting the reference as per the blog post:
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
form:
resources: ["bootstrap_3_layout.html.twig"]
in my config.yml
file, I get the following "error stack" in Symfony:
[3/3] Twig_Error_Loader: Unable to find template "bootstrap_3_layout.html.twig" in kernel.root_dir/Resources/views/base.html.twig at line 10.
[2/3] InvalidArgumentException: Unable to find template "bootstrap_3_layout.html.twig" : "The file "bootstrap_3_layout.html.twig" does not exist (in: /path-to-symfony/app/Resources).
[1/3] InvalidArgumentException: The file "bootstrap_3_layout.html.twig" does not exist (in: /path-to-symfony/app/Resources).
I added twig-bridge via composer, just in case, but that doesn't seem to resolve it.
The only location of a file with that name that I can find is at:
./vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig
.
If I put a breakpoint in the vendor/twig/twig/lib/Twig/Loader/Filesystem.php
file in the findTemplate method, a normal page goes through the process of iterating over $this->paths['__main__']
which has two entries:
I'm guessing that I need to somehow put the directory that the file is in into that paths array, but don't know how.
Can anyone point me in the direction of this (no doubt) simple solution?
Many thanks.
Upvotes: 2
Views: 1307
Reputation: 20191
Ok, the thing is that by defining twig > form > resources
, you're telling Symfony2
that you will have a custom resource located within your ./app/Resources
directory.
To resolve this, just copy/paste the file ./vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig
to ./app/Resources
and it should work.
Optionally, you could apply the theme to a each form individually, without touching config.yml
. I do it that way, because I like to have a complete control over which form gets rendered how.
Upvotes: 1