@@ -86,10 +86,20 @@ function(sfSelect, schemaForm, sfValidator) {
86
86
}
87
87
list . push ( dflt ) ;
88
88
}
89
+
90
+ // Trigger validation.
91
+ if ( scope . validateArray ) {
92
+ scope . validateArray ( ) ;
93
+ }
89
94
} ;
90
95
91
96
scope . deleteFromArray = function ( index ) {
92
97
list . splice ( index , 1 ) ;
98
+
99
+ // Trigger validation.
100
+ if ( scope . validateArray ) {
101
+ scope . validateArray ( ) ;
102
+ }
93
103
} ;
94
104
95
105
// Always start with one empty form unless configured otherwise.
@@ -149,8 +159,7 @@ function(sfSelect, schemaForm, sfValidator) {
149
159
if ( ngModel ) {
150
160
var error ;
151
161
152
- // Listen to an event so we can validate the input on request
153
- scope . $on ( 'schemaFormValidate' , function ( payload ) {
162
+ scope . validateArray = function ( ) {
154
163
// The actual content of the array is validated by each field
155
164
// so we settle for checking validations specific to arrays
156
165
@@ -161,12 +170,11 @@ function(sfSelect, schemaForm, sfValidator) {
161
170
form ,
162
171
scope . modelArray . length > 0 ? scope . modelArray : undefined
163
172
) ;
164
- console . log ( result . error )
165
173
if ( result . valid === false &&
166
174
result . error &&
167
175
( result . error . dataPath === '' ||
168
176
result . error . dataPath === '/' + form . key [ form . key . length - 1 ] ) ) {
169
- console . log ( 'setting invlid' )
177
+
170
178
// Set viewValue to trigger $dirty on field. If someone knows a
171
179
// a better way to do it please tell.
172
180
ngModel . $setViewValue ( scope . modelArray ) ;
@@ -176,8 +184,9 @@ function(sfSelect, schemaForm, sfValidator) {
176
184
} else {
177
185
ngModel . $setValidity ( 'schema' , true ) ;
178
186
}
187
+ } ;
179
188
180
- } ) ;
189
+ scope . $on ( 'schemaFormValidate' , scope . validateArray ) ;
181
190
182
191
183
192
scope . hasSuccess = function ( ) {
0 commit comments