wbraganca / yii2-dynamicform

It is widget to yii2 framework to clone form elements in a nested manner, maintaining accessibility.
Other
436 stars 438 forks source link

Duplicate form and will copy first form data #189

Open xuanzi23 opened 7 years ago

xuanzi23 commented 7 years ago

Hi, recently i using this plug in my project. I found out will duplicate form like example when i press '+' once will add many form at below.

Second problem is, when i save, after that i add new form will clone the first row data at below. I need clear it myself quite weird. anything will cause this thing happen?

kullarkert commented 7 years ago

I had same the problem with nested tables. Solution was to rename every nested table with parent index index.


<?php
DynamicFormWidget::begin([
    'widgetContainer' => 'dynamicform_inner',
    'widgetBody' => '.container-qvariants-'.$index,
    'widgetItem' => '.qvariant-item-'.$index,
    'limit' => 4,
    'min' => 2,
    'insertButton' => '.add-qvariant-'.$index,
    'deleteButton' => '.remove-qvariant-'.$index,
    'model' => $subModels[0],
    'formId' => 'dynamic-form',
    'formFields' => [
        'option',
        'points',
    ],
]);
?>
koquipizzi commented 6 years ago

I have the same issue. I don't have nested tables. @xuanzi23, can you resolve it?

VladimirBazhenov commented 5 years ago

@koquipizzi, I found a solution here, but now I can`t find the link (author, sorry):

// $toclone = $(widgetOptions.template); $toclone = _parseTemplate(widgetOptions);

in yii2-dynamic-form.js (_addItem method).