相关疑难解决方法(0)

symfony2多个嵌套表单原型

我想在另一个集合类型中包含一个集合类型.它应该如下所示:在此输入图像描述

只使用一个集合工作正常,但我需要编辑外部表单的原型,因此它为每一行呈现内部表单的原型.

任何想法我怎么能这样做?还有什么是最好的保存方式

编辑:现在我正在尝试渲染嵌套表单的原型:

  <ul class="characteristics-container" data-prototype="{{ form_widget(form.characteristics.vars.prototype)|e }}" data-prototype-options="{{ form_widget(form.characteristics.options.vars.prototype|e ) }}">
                    {# iterate over each existing tag and render its only field: name #}
                    {% for characteristic in form.characteristics %}
                        <li>{{ form_row(characteristic.name) }}</li>

                        <div class="characteristics-options">
                            {% for opt in form.characteristics.options %}

                            {% endfor %}                     
                        </div>


                    {% endfor %}
                </ul>
Run Code Online (Sandbox Code Playgroud)

它给出了错误 form_widget(form.characteristics.options.vars.prototype|e

Method "options" for object "Symfony\Component\Form\FormView" does not exist in 
Run Code Online (Sandbox Code Playgroud)

我尝试了特征[0],它说密钥不存在

这是我的表单类:

PromotionType(基本形式)

$builder              
            ->add('characteristics','collection', array(
                'label'         => 'Caracteristicas',
                 'type'         => new PromotionCharacteristicType(),
                 'allow_add'    => true,
                 'allow_delete' => …
Run Code Online (Sandbox Code Playgroud)

forms prototype nested-forms symfony

36
推荐指数
1
解决办法
2万
查看次数

标签 统计

forms ×1

nested-forms ×1

prototype ×1

symfony ×1