Home >php教程 >php手册 >贴一个自定义的 symfony 的表单皮肤 应用bootstrap效果

贴一个自定义的 symfony 的表单皮肤 应用bootstrap效果

WBOY
WBOYOriginal
2016-06-13 10:47:26983browse

效果如图

 

 

调用很方便


[html]
{% import "JcyHelperBundle:tmp:jcyForm.html.twig" as forms %} 
{{ forms.jcyForm(dbForm,path('JcyHelperBundle_db_set'),'Connect') }} 
{% import "JcyHelperBundle:tmp:jcyForm.html.twig" as forms %}
{{ forms.jcyForm(dbForm,path('JcyHelperBundle_db_set'),'Connect') }}
现在上源代码[html]
{% macro jcyForm(form,action,submit_name,onSubmitJs) %} 

 
{% if form.vars.errors|length >0 %} 
 
{% for error in form.vars.errors %} 
{% if loop.index>1 %}
{% endif %} 
{{ error.messageTemplate|trans(error.messageParameters, 'validators') }} 
{% endfor %} 
 
{% endif %} 
{% for key,v in form.children %} 
{% if key != '_token' %} 
 
   
 
     
       
 
            {{ form_widget(v) }} 
             
            {% if v.vars.errors|length >0 %} 
            {% for error in v.vars.errors %} 
            {% if loop.index>1 %},{% endif %} 
            {{ error.messageTemplate|trans(error.messageParameters, 'validators') }} 
            {% endfor %} 
            {% endif %} 
           
 
       
 
   
 
 
{% endif %} 
{% endfor %} 
{{ form_rest(form) }} 
 
 
{% endmacro %}
摘自 jiaochangyun的专栏
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn