Open maheshtc opened 9 years ago
I actually have a similar situation. It doesn't happen when creating, only when updating. For me it happens to textareas, dropdown menus and nested forms.
You can get around textarea text cloning by adding this event:
$(".dynamicform_wrapper").on("afterInsert", function(e, item) {
$(item).find(".textareaclass").val("");
});
It basically looks like it is cloning the first element not an empty element.
A dirty fix, for this jquery problem is to In yii2-dynamic-form.js line 68: add the.text option $template.find('input, textarea, select').each(function() { $(this).val(''); $(this).text(''); });
$(this).text('');
this removes the whole content of a dropdownlist.
I have this situation with my radio buttons, and the problem is that in the update, whenever I add an item dynamic-form always sends me the first model of the array; instead of sending me a new model
Possible solution i used:
$(".dynamicform_wrapper").on("afterInsert", function(e, item) { $(item).find('.applicationListID').select2("val", ""); $(item).find('.serviceID').val(""); });
I came across one issue, When I click on [+] Add Item button, It is cloning first panel and It is working correctly. But If I have textarea as form element, It takes value of textarea from first panel. It should be blank after Add Item but it is not.
I am attaching screenshot of before and after.
Please correct me if wrong anywhere. I am using similar code to address example.