我更新了我的项目到Symfony4。当我进入一些有表单的页面时,出现了这个错误。
Unable to find template "StarRatingBundle::rating.html.twig"
(looked into: /templates, /templates, \vendor\symfony\twig-bridge/Resources/views/Form).
我使用了 blackknight467/star-rating-bundle
捆绑包,它提供了一个树枝扩展来拥有一个星级评价系统。错误中的模板位于这个捆绑包中。Resources/views
文件夹。
Twig.yaml :
twig:
paths: ['%kernel.project_dir%/templates']
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
form_themes:
- 'Form/fields.html.twig'
Symfony 4+不支持 "x:x:x.html.twig "符号。你需要安装 composer require templating
然后在你的framework.yaml中加入以下内容来激活它。
templating:
engines: ['twig']
.
Files > Invalidate caches & restart. 这应该允许Symfony找到你的模板。