Symfony2->树枝->表格 ->字段 ->设置渲染 = true字段、树枝、表格、gt

2023-09-07 00:10:53 作者:小思绪大情节

i have a simple problem.

I have a form with a field for example:

$builder
    ->add('x')
    ->add('y')
    ->add('z')
;
安普广通 hbguangtong AMPGT A500 A

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.