我有这个包含
main.html.twig
{% set vars ={'id': user.id,'order': 'true'} %}
{% include "BDMOrderBundle::OrderForm.html.twig" with vars %}
OrderForm.html.twig
{{ form_start(form, {'action': path('myaction',{'id': post.id,'order':order})}) }}
我可以使用
更改id
中的order
和OrderForm.html.twig
吗?
{{ form_start(form, {'action': path('myaction',vars)}) }}
答案 0 :(得分:0)
试
{% include "BDMOrderBundle::OrderForm.html.twig" with {'vars': vars} %}
当你做
时{% include "BDMOrderBundle::OrderForm.html.twig" with vars %}
与
相同{% include "BDMOrderBundle::OrderForm.html.twig" with {'id': user.id,'order': 'true'} %}
所以真正传递给BDMOrderBundle::OrderForm.html.twig
的是一个数组,而不是'vars'变量