formapro / JsFormValidatorBundle

The Javascript validation for Symfony 2, 3 and 4 forms
MIT License
128 stars 56 forks source link

Issue in collections validation #139

Open igoryasko31 opened 6 years ago

igoryasko31 commented 6 years ago

The issue occurs in the 'addPrototype' method.

var prototype = FpJsFormValidator.preparePrototype( FpJsFormValidator.cloneObject(item.jsFormValidator.prototype), name, item.jsFormValidator.id + '_' + name );

The third parameter of the method 'preparePrototype' is the 'Id' of element + unique index. The method replaces the substring 'name' of the prototype to the third parameter.
As result, the ID contains a duplicate of the substring. The example below: _ID (passed as the third parameter): checkout_info_orderItems_0_delegates1 _ID after 'preparePrototype' calls: checkout_info_orderItems_0_delegates_checkout_info_orderItems_0_delegates_1phone

I think the 'preparePrototype' method should get the only unique index as the third parameter. Does it make sense?

66Ton99 commented 6 years ago

Why not? PR are welcome.

pk16011990 commented 6 years ago

my fix is in https://github.com/shopsys/shopsys/pull/180

It is about replace id to name.