formapro / JsFormValidatorBundle

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

Does `findRealChildElement` have a proper behaviour? #135

Open giovannialbero1992 opened 6 years ago

giovannialbero1992 commented 6 years ago

I add all models in page (also for forms that i've not included in page). So i've observed that if a single child of form match js model validation, the js validation is attached to entire form. Should not it be more correct that all child elements match form elements?

Now:

           for (var childName in element.children) {
                child = element.children[childName].domNode;
                if (child) {
                    break;
                }
            }

Suggest:

           for (var childName in element.children) {
                child = element.children[childName].domNode;
                if (! child) {
                    return null;
                }
            }

I hope I have been able to explain. I can apply a PR on this if my suggest is correct.

giovannialbero1992 commented 6 years ago

I add that I've a conflict name in my case so there is an input field with same name of another js form validator model.