Form: fix form-item resetFields (#3830) (#3840)

pull/3906/head
pengchongfu 2017-03-30 11:33:44 +08:00 committed by baiyaaaaa
parent 262ac629a2
commit 88d4a390d0
1 changed files with 8 additions and 4 deletions

View File

@ -161,10 +161,10 @@
let prop = getPropByPath(model, path); let prop = getPropByPath(model, path);
if (Array.isArray(value) && value.length > 0) { if (Array.isArray(value)) {
this.validateDisabled = true; this.validateDisabled = true;
prop.o[prop.k] = []; prop.o[prop.k] = [].concat(this.initialValue);
} else if (value !== '') { } else {
this.validateDisabled = true; this.validateDisabled = true;
prop.o[prop.k] = this.initialValue; prop.o[prop.k] = this.initialValue;
} }
@ -200,8 +200,12 @@
if (this.prop) { if (this.prop) {
this.dispatch('ElForm', 'el.form.addField', [this]); this.dispatch('ElForm', 'el.form.addField', [this]);
let initialValue = this.fieldValue;
if (Array.isArray(initialValue)) {
initialValue = [].concat(initialValue);
}
Object.defineProperty(this, 'initialValue', { Object.defineProperty(this, 'initialValue', {
value: this.fieldValue value: initialValue
}); });
let rules = this.getRules(); let rules = this.getRules();