Skip to content
This repository was archived by the owner on Jul 1, 2020. It is now read-only.

Commit aa4b874

Browse files
committed
Fixed small issue with pulling form name
In some occasion, trying to find the parent form and the form name of an input element was giving the wrong result. We should call instead `form.getAttribute("name")` for correct result.
1 parent da5e972 commit aa4b874

File tree

6 files changed

+24
-19
lines changed

6 files changed

+24
-19
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-validation-ghiscoding",
3-
"version": "1.4.11",
3+
"version": "1.4.12",
44
"author": "Ghislain B.",
55
"description": "Angular-Validation Directive and Service (ghiscoding)",
66
"main": [

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Angular-Validation change logs
22

3+
1.4.12 (2015-11-01) Fixed a small issue with pulling the form name when trying to find the parent form of an input element.
34
1.4.11 (2015-10-29) Enhancement #75 - Added custom rules validation through custom functions. Fixed issue #76 - problem with ui-mask in directive.
45
1.4.10 (2015-10-12) Sanitized error messages. Fixed issue #69 - Stop when invalid characters typed on input[number].
56
1.4.9 (2015-10-05) Enhancement #57, #66, #67 - Added 3rd party addon validation (like ngTagsInput, Angular Multiselect, Dropdown multi-select, etc...)

dist/angular-validation.min.js

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-validation-ghiscoding",
3-
"version": "1.4.11",
3+
"version": "1.4.12",
44
"author": "Ghislain B.",
55
"description": "Angular-Validation Directive and Service (ghiscoding)",
66
"main": "app.js",

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Angular Validation (Directive / Service)
2-
`Version: 1.4.11`
2+
`Version: 1.4.12`
33
### Form validation after user inactivity of default 1sec. (customizable timeout)
44

55
Forms Validation with Angular made easy! Angular-Validation is an angular directive/service with locales (languages) with a very simple approach of defining your `validation=""` directly within your element to validate (input, textarea, etc) and...that's it!!! The directive/service will take care of the rest!

src/validation-common.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,12 @@ angular
149149
_globalOptions.controllerAs.$validationSummary = _validationSummary;
150150

151151
// also save it inside controllerAs form (if found)
152-
if (!!form) {
152+
if (!!form && !!form.$name) {
153153
var formName = form.$name.indexOf('.') >= 0 ? form.$name.split('.')[1] : form.$name;
154154
var ctrlForm = (!!_globalOptions.controllerAs[formName]) ? _globalOptions.controllerAs[formName] : self.elm.controller()[formName];
155-
ctrlForm.$validationSummary = arrayFindObjects(_validationSummary, 'formName', form.$name);
155+
if(!!ctrlForm) {
156+
ctrlForm.$validationSummary = arrayFindObjects(_validationSummary, 'formName', form.$name);
157+
}
156158
}
157159
}
158160

@@ -738,15 +740,16 @@ angular
738740

739741
for (var i = 0; i < forms.length; i++) {
740742
var form = forms[i].form;
743+
var formName = form.getAttribute("name");
741744

742-
if (!!form && !!form.name) {
743-
parentForm = (!!_globalOptions && !!_globalOptions.controllerAs && form.name.indexOf('.') >= 0)
744-
? explodedDotNotationStringToObject(form.name, self.scope)
745-
: self.scope[form.name];
745+
if (!!form && !!formName) {
746+
parentForm = (!!_globalOptions && !!_globalOptions.controllerAs && formName.indexOf('.') >= 0)
747+
? explodedDotNotationStringToObject(formName, self.scope)
748+
: self.scope[formName];
746749

747750
if(!!parentForm) {
748751
if (typeof parentForm.$name === "undefined") {
749-
parentForm.$name = form.name; // make sure it has a $name, since we use that variable later on
752+
parentForm.$name = formName; // make sure it has a $name, since we use that variable later on
750753
}
751754
return parentForm;
752755
}
@@ -755,14 +758,17 @@ angular
755758

756759
// falling here with a form name but without a form object found in the scope is often due to isolate scope
757760
// we can hack it and define our own form inside this isolate scope, in that way we can still use something like: isolateScope.form1.$validationSummary
758-
if (!!form && !!form.name) {
759-
var obj = { $name: form.name, specialNote: 'Created by Angular-Validation for Isolated Scope usage' };
761+
if (!!form) {
762+
var formName = form.getAttribute("name");
763+
if(!!formName) {
764+
var obj = { $name: formName, specialNote: 'Created by Angular-Validation for Isolated Scope usage' };
760765

761-
if (!!_globalOptions && !!_globalOptions.controllerAs && form.name.indexOf('.') >= 0) {
762-
var formSplit = form.name.split('.');
763-
return self.scope[formSplit[0]][formSplit[1]] = obj
766+
if (!!_globalOptions && !!_globalOptions.controllerAs && formName.indexOf('.') >= 0) {
767+
var formSplit = formName.split('.');
768+
return self.scope[formSplit[0]][formSplit[1]] = obj
769+
}
770+
return self.scope[formName] = obj;
764771
}
765-
return self.scope[form.name] = obj;
766772
}
767773
return null;
768774
}

0 commit comments

Comments
 (0)