Twig 在symfony 2.3中呈现除提交之外的所有字段
我正在覆盖SensioGeneratorBundle的骨架模板,如中所述: 所以在这之前一切都很好 在SensioGeneratorBundle的其中一个模板中,我有:Twig 在symfony 2.3中呈现除提交之外的所有字段,twig,symfony-forms,symfony-2.3,Twig,Symfony Forms,Symfony 2.3,我正在覆盖SensioGeneratorBundle的骨架模板,如中所述: 所以在这之前一切都很好 在SensioGeneratorBundle的其中一个模板中,我有: # app/resources/SensioGeneratorBundle/skeleton/crud/views/new.html.twig.twig {% block body %} {{ "{% block page_title 'Incluir " ~ entity ~ "'%}" }} {{ "{% block
# app/resources/SensioGeneratorBundle/skeleton/crud/views/new.html.twig.twig
{% block body %}
{{ "{% block page_title 'Incluir " ~ entity ~ "'%}" }}
{{ "{% block body -%}" }}
{{ '{{ form(form) }}' }}
{% set hide_edit, hide_delete = true, true %}
{% include 'crud/views/others/record_actions.html.twig.twig' %}
{{ "{% endblock %}" }}
{% endblock body %}
这是可行的,但是{form(form)}}正在呈现提交按钮,我想呈现记录_actions.html.twig.twig中的提交按钮
因此,我的问题是:如何在不呈现提交按钮的情况下呈现表单?请记住,我正试图在骨架模板中实现这一点,在这一刻,我没有表单的边界来迭代它
谢谢 此问题的解决方案如下:
# app/resources/SensioGeneratorBundle/skeleton/crud/views/new.html.twig
{% block body %}
{{ "{% block page_title 'Incluir " ~ entity ~ "'%}" }}
{{ "{% block body -%}" }}
{{ " {{ form_start(child) }}" }}
{{ " {% for child in form %}" }}
{{ " {% if child.vars.name != 'submit' %}" }}
{{ " {{ form_row(child) }}" }}
{{ " {% endif %}" }}
{{ " {% endfor %}" }}
{% set hide_edit, hide_delete = true, true %}
{% include 'crud/views/others/record_actions.html.twig.twig' %}
{{ "{% endblock %}" }}
{% endblock body %}
在record_actions.html.twig.twig
# app/resources/SensioGeneratorBundle/skeleton/crud/views/record_actions.html.twig
{{ " {{ form_row(form.submit) }}" }}
{{ " {{ form_end(form) }}" }}
<ul class="record_actions">
<li>
<a href="{{ "{{ path('" ~ route_name_prefix ~ "') }}" }}">
Back to the list
</a>
</li>
{% if ('edit' in actions) and (not hide_edit) %}
<li>
<a href="{{ "{{ path('" ~ route_name_prefix ~ "_edit', { 'id': entity.id }) }}" }}">
Edit
</a>
</li>
{% endif %}
{% if ('delete' in actions) and (not hide_delete) %}
<li>
<form action="{{ "{{ path('" ~ route_name_prefix ~ "_delete', { 'id': entity.id }) }}" }}" method="post">
<input type="hidden" name="_method" value="DELETE" />
{{ '{{ form_widget(delete_form) }}' }}
<button type="submit">Delete</button>
</form>
</li>
{% endif %}
</ul>
#app/resources/SensioGeneratorBundle/skeleton/crud/views/record#u actions.html.twig
{{{{form_row(form.submit)}}}}}
{{{{form_end(form)}}}}}
-
{%if('edit'在操作中)和(非hide_edit)%}
-
{%endif%}
{%if('delete'在操作中)和(而不是hide_delete)%}
-
{{{form_widget(delete_form)}}}}}
删除
{%endif%}