获取vars Twig模板

时间:2014-12-18 16:11:17

标签: symfony twig

我有这个包含

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中的orderOrderForm.html.twig吗?
{{ form_start(form, {'action': path('myaction',vars)}) }}

1 个答案:

答案 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'变量