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

Textarea takes default value of first panel when click add new item #44

Open maheshtc opened 9 years ago

maheshtc commented 9 years ago

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.

screenshot from 2015-06-02 16 17 08

screenshot from 2015-06-02 16 17 37

Please correct me if wrong anywhere. I am using similar code to address example.

kaarleenzz commented 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.

dahape commented 9 years ago

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(''); });

quackadillyblip commented 8 years ago

$(this).text(''); this removes the whole content of a dropdownlist.

ricar2ce commented 6 years ago

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

3dgroup commented 6 years ago

Possible solution i used:

$(".dynamicform_wrapper").on("afterInsert", function(e, item) { $(item).find('.applicationListID').select2("val", ""); $(item).find('.serviceID').val(""); });