Skip to content

Allow broadcasting of the formName to validate #589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/directives/schema-validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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;
Expand Down