1
0
mirror of synced 2024-11-22 05:16:05 +03:00

Fixes bug causing FormulateElement's initial prop to occasionally be overwritten by the Formulate initial prop

This commit is contained in:
Justin Schroeder 2018-02-15 23:55:36 -05:00
parent f46a0f66c8
commit fde067d974
3 changed files with 14 additions and 7 deletions

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -47,7 +47,8 @@ export default {
data () {
return {
parentIdentifier: 'vue-formulate-wrapper-element',
forceErrors: null
forceErrors: null,
fieldInitials: {}
}
},
computed: {
@ -80,18 +81,21 @@ export default {
return this.showErrors
}
return this.behavior === 'live'
},
mergedInitial () {
return Object.assign({}, Object.assign({}, this.initial), this.fieldInitials)
}
},
watch: {
initial () {
this.hydrate(this.initial)
mergedInitial () {
this.hydrate(this.mergedInitial)
}
},
created () {
this.hydrate(this.initial)
this.hydrate(this.mergedInitial)
},
mounted () {
this.hydrate(this.initial)
this.hydrate(this.mergedInitial)
},
methods: {
registerField (field, data) {
@ -110,6 +114,9 @@ export default {
}
this.updateFormValidation()
},
setInitial (field, value) {
this.fieldInitials[field] = value
},
update (change) {
this.$store.commit(`${this.m}setFieldValue`, Object.assign(change, {
form: this.name

View File

@ -294,7 +294,7 @@ export default {
filter(this.$props, (prop, value) => ['name', 'type', 'id', 'label', 'validation', 'validationLabel'].includes(prop))
)
if (this.initial !== false) {
this.form.hydrate({[this.name]: this.initial})
this.form.setInitial(this.name, this.initial)
}
}
}