Symfony2->树枝->表格 ->字段 ->设置渲染 = true [英] Symfony2 -> Twig -> Form -> Field -> Set rendered = true
本文介绍了Symfony2->树枝->表格 ->字段 ->设置渲染 = true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i have a simple problem.
I have a form with a field for example:
$builder
->add('x')
->add('y')
->add('z')
;
In my twig files i used multiple blocks and i want to stop render fields... I view the b.html.twig file!
a.html.twig
{% block body %}
{% block form %}
{{ form_widget(form) }}
{% endblock form %}
{% endblock body %}
b.html.twig
{% block form %}
{{ form.x.set('rendered', true) | default() }}
{{ parent() }}
{% endblock form %}
If i remove the "default()" i get the error, that the object cant be converted to a string. And actually the form renders all fields... Inclusive the x field. But they shouldnt render the x field...
Thank you in advance!
解决方案
Am I missing the question here? If you want to set a field as rendered even though it is not the simple call is:
{% do form.x.setRendered %}
If I misunderstood, my apologies.
这篇关于Symfony2->树枝->表格 ->字段 ->设置渲染 = true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文