diff --git a/src/directives/schema-validate.js b/src/directives/schema-validate.js index 3b96351bd..a606c50c8 100644 --- a/src/directives/schema-validate.js +++ b/src/directives/schema-validate.js @@ -106,7 +106,13 @@ angular.module('schemaForm').directive('schemaValidate', ['sfValidator', '$parse var schema = form.schema; // A bit ugly but useful. - scope.validateField = function() { + scope.validateField = function(formName) { + + // If we have specified a form name, and this model is not within + // that form, then leave things be. + if(formName != undefined && ngModel.$$parentForm.$name !== formName) { + return; + } // Special case: arrays // TODO: Can this be generalized in a way that works consistently? @@ -153,7 +159,9 @@ angular.module('schemaForm').directive('schemaValidate', ['sfValidator', '$parse }); // Listen to an event so we can validate the input on request - scope.$on('schemaFormValidate', scope.validateField); + scope.$on('schemaFormValidate', function(event, formName) { + scope.validateField(formName); + }); scope.schemaError = function() { return error;