php – 创建Symfony2表单主题 – 字段集和列表样式

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – 创建Symfony2表单主题 – 字段集和列表样式脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用symfony2.我试图覆盖树枝中的认div样式表单块.

首先,有没有或知道fieldset和list(ul – > li)方法的可用实现?

目前,我实现了这样的fieldset支持

在类型中:

public function buildView(FormView $view,FormInterface $form,array $options)
{
    $view->setattribute('fieldsets',array(
                array(
                    'legend' => 'film.group.date','content'=> array(
                        'theaters_release_date','storage_media_release','storage_media_release_date','vod_release_date'
                        )),array(
                    'legend' => 'film.group.country','content'=> array('countries')),));
}@H_403_10@ 
 

我有一个名为fieldset.htML.twig的模板,它使用视图的属性

{% macro fieldset_block(fieldset,form) %}
<fieldset{% if fieldset.subform is defined %} class="{{ fieldset.subform }}"{% endif %}>
    <legend>{{fieldset.legend | trans }}</legend>
    {% if fieldset.content is defined%}
      {% for row in fieldset.content %}
          {{ form_row(form[row]) }}
      {% enDFor %}
    {% endif %}
    {% if fieldset.subform is defined %}
        {# Couldn't get some recursivITy (simply call form widget) here... too bad #}
        {% if form[fieldset.subform].get('attr').fieldsets is defined %}
            {% for subfieldset in form[fieldset.subform].get('attr').fieldsets %}
                {{ _self.fieldset_block(subfieldset,form[fieldset.subform]) }}
            {% endfor %}
        {% else %}
            {% for row in form[fieldset.subform] %}
                {{ form_row(row) }}
            {% endfor %}
        {% endif %}
    {% endif %}
    {% if fieldset.items is defined%}
      {% for fieldset in fieldset.items %}
          {{ _self.fieldset_block(fieldset,form) }}
      {% endfor %}
    {% endif %}
</fieldset>
{%  endmacro %}

{% block form_widget %}
    {% for fieldset in form.get('attr').fieldsets %}
        {{ _self.fieldset_block(fieldset,form) }}
    {% endfor %}
{% endblock %}@H_403_10@

脚本宝典总结

以上是脚本宝典为你收集整理的php – 创建Symfony2表单主题 – 字段集和列表样式全部内容,希望文章能够帮你解决php – 创建Symfony2表单主题 – 字段集和列表样式所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。