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


    文章转自:http://blog.csdn.net/jiaochangyun/article/details/7245009#

    效果如图

    调用很方便

    1. {% import "JcyHelperBundle:tmp:jcyForm.html.twig" as forms %} 
    2. {{ forms.jcyForm(dbForm,path('JcyHelperBundle_db_set'),'Connect') }} 
    {% import "JcyHelperBundle:tmp:jcyForm.html.twig" as forms %}
    {{ forms.jcyForm(dbForm,path('JcyHelperBundle_db_set'),'Connect') }}
    

    现在上源代码

    1. {% macro jcyForm(form,action,submit_name,onSubmitJs) %} 
    2. <formaction="{{ action }}"method="post"onsubmit="{{ onSubmitJs|default('') }}" {{ form_enctype(form) }}> 
    3. {% if form.vars.errors|length >0 %} 
    4. <divclass="alert alert-error"> 
    5. {% for error in form.vars.errors %} 
    6. {% if loop.index>1 %}<br>{% endif %} 
    7. {{ error.messageTemplate|trans(error.messageParameters, 'validators') }} 
    8. {% endfor %} 
    9. </div> 
    10. {% endif %} 
    11. {% for key,v in form.children %} 
    12. {% if key != '_token' %} 
    13. <divclass="control-group{% if v.vars.errors|length >0 %} error{% endif %}"> 
    14.     <divclass="input-prepend"> 
    15.     <labelclass="control-label add-on"style="60px;text-align:right"for="{{v.vars.id}}">{{v.vars.label}} :</label> 
    16.         <divclass="controls"> 
    17.             {{ form_widget(v) }} 
    18.             <spanclass="help-inline"> 
    19.             {% if v.vars.errors|length >0 %} 
    20.             {% for error in v.vars.errors %} 
    21.             {% if loop.index>1 %},{% endif %} 
    22.             {{ error.messageTemplate|trans(error.messageParameters, 'validators') }} 
    23.             {% endfor %} 
    24.             {% endif %} 
    25.             </span> 
    26.         </div> 
    27.     </div> 
    28. </div> 
    29. {% endif %} 
    30. {% endfor %} 
    31. {{ form_rest(form) }} 
    32. <inputtype=submitid="submit_btn"class="btn-primary span2"value="{{ submit_name }}"> 
    33. </form> 
    34. {% endmacro %} 
  • 相关阅读:
    检查使用的端口
    time is always agains us
    检查使用的端口
    dreque问题一例
    查看重定向的输出
    安装VSS时,Um.dat may be corrupt
    修改网卡ip
    redis install on ubuntu/debian
    上火了
    学这么多技术是为什么
  • 原文地址:https://www.cnblogs.com/Kakasi/p/2881026.html
Copyright © 2020-2023  润新知