Skip to content

Commit 2a0452b

Browse files
autoValidate and special case for mm-repeater in mm-form
1 parent b5e8158 commit 2a0452b

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

src/mm-form/index.html

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,6 @@
163163
label: 'Select a Color'
164164
},
165165
'repeater': {
166-
// TODO: Do the validation in the form
167-
// validation: function(name, value, data, field, view) {
168-
// return field.validate();
169-
// },
170-
parentEle: null,
171-
errorMsgEle: null,
172-
errorMsg: 'You need to select some stuff',
173166
label: 'Repeat Things'
174167
}
175168
// 'empty' : {}
@@ -198,8 +191,6 @@
198191
testForm.config = config;
199192
// testForm.data = data;
200193

201-
202-
203194
testForm.addEventListener('serialize-form', function(e){
204195
console.log('serialize-form', e.detail);
205196
});

src/mm-form/mm-form.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
value: true,
3030
notify: true
3131
},
32+
autoValidate: {
33+
type: Boolean,
34+
value: true
35+
},
3236
// Footer related
3337
footerMessages: {
3438
type: Object,
@@ -275,7 +279,7 @@
275279
this.unsaved = this._diffData();
276280
}
277281

278-
if (validation) this._validateField(key, value);
282+
if (validation && this.autoValidate) this._validateField(key, value);
279283

280284
// show messaging in the footer
281285
if (this.unsaved && this.showUnsavedMessage) {
@@ -338,6 +342,15 @@
338342
} else if (validation && noValidate) {
339343
// clean up prior validations if they were there
340344
this.resetFieldValidation(key);
345+
} else {
346+
// special case for mm-repeater
347+
// mm-repeater will handle it's own validation
348+
var field = this.config[key].field,
349+
tagName = field.tagName.toLowerCase();
350+
351+
if (tagName === 'mm-repeater') {
352+
field.validate();
353+
}
341354
}
342355

343356
// show messaging in the footer
@@ -350,7 +363,7 @@
350363
},
351364

352365
_validateField: function(key, value) {
353-
var valid = null,
366+
var valid = false,
354367
field = this.config[key].field,
355368
validation = this.config[key].validation,
356369
errorMsg = this.config[key].errorMsg,

0 commit comments

Comments
 (0)