Fixes bug causing FormulateElement's initial prop to occasionally be overwritten by the Formulate initial prop
This commit is contained in:
parent
f46a0f66c8
commit
fde067d974
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user