Skip to content

Commit a893948

Browse files
committed
Migrate PR #656 to webpack branch
1 parent d6eceb8 commit a893948

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

src/directives/field.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,17 @@ sfPath, sfSelect) {
5252
} else if (angular.isString(form.onClick)) {
5353
if (sfSchema) {
5454
//evaluating in scope outside of sfSchemas isolated scope
55-
sfSchema.evalInParentScope(form.onClick, {'$event': $event, form: form});
55+
sfSchema.evalInParentScope(form.onClick, { '$event': $event, form: form });
5656
} else {
57-
scope.$eval(form.onClick, {'$event': $event, form: form});
57+
scope.$eval(form.onClick, { '$event': $event, form: form });
5858
}
5959
}
6060
};
6161

6262
/**
6363
* Evaluate an expression, i.e. scope.$eval
6464
* but do it in sfSchemas parent scope sf-schema directive is used
65+
*
6566
* @param {string} expression
6667
* @param {Object} locals (optional)
6768
* @return {Any} the result of the expression
@@ -160,16 +161,25 @@ sfPath, sfSelect) {
160161
// It looks better with dot notation.
161162
scope.$on(
162163
'schemaForm.error.' + form.key.join('.'),
163-
function(event, error, validationMessage, validity) {
164+
function(event, error, validationMessage, validity, formName) {
165+
// validationMessage and validity are mutually exclusive
166+
formName = validity;
164167
if (validationMessage === true || validationMessage === false) {
165168
validity = validationMessage;
166169
validationMessage = undefined;
167-
}
170+
};
171+
172+
// If we have specified a form name, and this model is not within
173+
// that form, then leave things be.
174+
if (formName != undefined && scope.ngModel.$$parentForm.$name !== formName) {
175+
return;
176+
};
168177

169178
if (scope.ngModel && error) {
170179
if (scope.ngModel.$setDirty) {
171180
scope.ngModel.$setDirty();
172-
} else {
181+
}
182+
else {
173183
// FIXME: Check that this actually works on 1.2
174184
scope.ngModel.$dirty = true;
175185
scope.ngModel.$pristine = false;

src/services/decorators.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -231,20 +231,29 @@ export default function($compileProvider, sfPathProvider) {
231231
// It looks better with dot notation.
232232
scope.$on(
233233
'schemaForm.error.' + form.key.join('.'),
234-
function(event, error, validationMessage, validity) {
234+
function(event, error, validationMessage, validity, formName) {
235+
// validationMessage and validity are mutually exclusive
236+
formName = validity;
235237
if (validationMessage === true || validationMessage === false) {
236238
validity = validationMessage;
237239
validationMessage = undefined;
238-
}
240+
};
241+
242+
// If we have specified a form name, and this model is not within
243+
// that form, then leave things be.
244+
if (formName != undefined && scope.ngModel.$$parentForm.$name !== formName) {
245+
return;
246+
};
239247

240248
if (scope.ngModel && error) {
241249
if (scope.ngModel.$setDirty) {
242250
scope.ngModel.$setDirty();
243-
} else {
251+
}
252+
else{
244253
// FIXME: Check that this actually works on 1.2
245254
scope.ngModel.$dirty = true;
246255
scope.ngModel.$pristine = false;
247-
}
256+
};
248257

249258
// Set the new validation message if one is supplied
250259
// Does not work when validationMessage is just a string.

0 commit comments

Comments
 (0)