Symfony 2 - 表单主题 - 覆盖块渲染两次 [英] Symfony 2 - Form theming - Overriden block renders two times

查看:36
本文介绍了Symfony 2 - 表单主题 - 覆盖块渲染两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试自定义主题表单提交按钮,但此按钮被呈现两次.第一次覆盖块时,第二次在我的表单中使用它时.

I'm trying to customize a theme form submit button but this button is being rendered two times. The first time when the block is overriden and the second time when i'm using it in my form.

这是代码和结果.

非常感谢.

{# src/YagoQuinoy/Simple/BlogBundle/Resources/views/Blog/searchArtciles.html.twig #}

{% form_theme form _self %}

{% block submit_widget %}
    <button><i class="fa fa-bicycle"></i></button>
{% endblock submit_widget %}

{{ form_start(form, {'attr': {'novalidate': 'novalidate'}}) }}
{{ form_errors(form.search) }}
{{ form_widget(form.search) }}
{{ form_widget(form.submit, {'attr': {'class': 'e-search-articles-submit'}}) }}
{{ form_end(form) }}

图片链接(没有 10 声望 ¬¬)双渲染按钮图片

Link to the image (don't have 10 reputation ¬¬) Double rendered button image

推荐答案

使用文档中建议的分隔模板文件解决.

Solved using separated template file like is suggested in documentation.

http://symfony.com/doc/current/cookbook/form/form_customization.html#method-2-inside-a-separate-template

这篇关于Symfony 2 - 表单主题 - 覆盖块渲染两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆