Skip to content

Commit 1dc6fc8

Browse files
committed
Merge pull request json-schema-form#589 from tomsowerby/patch-1
Allow broadcasting of the formName to validate
2 parents 17f91c2 + 4ec1c57 commit 1dc6fc8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/directives/schema-validate.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,13 @@ angular.module('schemaForm').directive('schemaValidate', ['sfValidator', '$parse
106106
var schema = form.schema;
107107

108108
// A bit ugly but useful.
109-
scope.validateField = function() {
109+
scope.validateField = function(formName) {
110+
111+
// If we have specified a form name, and this model is not within
112+
// that form, then leave things be.
113+
if(formName != undefined && ngModel.$$parentForm.$name !== formName) {
114+
return;
115+
}
110116

111117
// Special case: arrays
112118
// TODO: Can this be generalized in a way that works consistently?
@@ -153,7 +159,9 @@ angular.module('schemaForm').directive('schemaValidate', ['sfValidator', '$parse
153159
});
154160

155161
// Listen to an event so we can validate the input on request
156-
scope.$on('schemaFormValidate', scope.validateField);
162+
scope.$on('schemaFormValidate', function(event, formName) {
163+
scope.validateField(formName);
164+
});
157165

158166
scope.schemaError = function() {
159167
return error;

0 commit comments

Comments
 (0)