-
Notifications
You must be signed in to change notification settings - Fork 58
Conversation
Previous code retrieved first form on page, and exited if that form did not have a name. This change will let it get first form with a name within scope. Useful if, like in my case, there are several forms on the page that are out of my control.
Oh yes you are right, I assumed that most people would have a name on the Form. Your indentation seems a little offset at some areas, it might have to do 2 commits to fix that unless you want to fix it. Thanks for the help |
fixed offset indents
I guess I don't really know, I just used my case as a sample. The indentations should be fixed now. |
should be spaces, not tabs
Oh wow, this is nice knowing that my code is now used on large application, it's good for the ego hehe. I will probably push your code as is, since in my cases I also develop with the idea of 1 form per page so that wouldn't affect my side either. Unless we verify that there is at least 1 "validation" attribute in the list of elements that belongs to the form that your Again thanks a lot for the help, really appreciate it, which is also why I made it open to the big community of Open Source :) |
I don't see why not... |
Alright, I made some more code changes, added and tested that it works properly. To make sure that the form you found (with your code) really has children with /** Make sure the Form has at least 1 child element with a validation attribute
* @param object form
* @return bool
*/
function hasValidationAttributes(form) {
for(var i = 0, ln = form.elements.length; i < ln; i++) {
if(!!form.elements[i].getAttribute('validation')) {
return true;
}
}
return false;
} and finally modified your line 292 with an extra call to the new function if (form && form.name && self.scope[form.name] && hasValidationAttributes(form)) { If you could make all your tests at your work and make sure that everything works as intended, I would be happy to have a revised pull request including the piece that I added. As a side note, I found and fixed a little bug in my new Thanks again |
Actually forget my code, I just found out that it breaks my other page when using Form with only the Service since the html doesn't have validation attributes. So I will accept your code as is, I will have to find another way on making sure it's the same form. |
- Recompiled minified script after pull request #15
Hi there, I just want to let you know that I had to redo and replace the I hope this will not break your code but since I don't have a way to test your code, I prefer to advise you... Let me know if something is broken on your side. I tried on my side with/without names on the form and it seems all good. Prior to this change, the $validationSummary was never really separated, it was always having the errors of all the forms, now it's fixed. You can see the example with multiple form on my main page demo. Try it out. Hopefully it's still all good. |
Thanks for the heads-up. |
Previous code retrieved first form on page, and exited if that form did not have a name.
This change will let it get first form with a name within scope.
Needed if, like in my case, there are several nameless forms on the page that are out of my control and out of scope.