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 () {
|
data () {
|
||||||
return {
|
return {
|
||||||
parentIdentifier: 'vue-formulate-wrapper-element',
|
parentIdentifier: 'vue-formulate-wrapper-element',
|
||||||
forceErrors: null
|
forceErrors: null,
|
||||||
|
fieldInitials: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -80,18 +81,21 @@ export default {
|
|||||||
return this.showErrors
|
return this.showErrors
|
||||||
}
|
}
|
||||||
return this.behavior === 'live'
|
return this.behavior === 'live'
|
||||||
|
},
|
||||||
|
mergedInitial () {
|
||||||
|
return Object.assign({}, Object.assign({}, this.initial), this.fieldInitials)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
initial () {
|
mergedInitial () {
|
||||||
this.hydrate(this.initial)
|
this.hydrate(this.mergedInitial)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
this.hydrate(this.initial)
|
this.hydrate(this.mergedInitial)
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
this.hydrate(this.initial)
|
this.hydrate(this.mergedInitial)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
registerField (field, data) {
|
registerField (field, data) {
|
||||||
@ -110,6 +114,9 @@ export default {
|
|||||||
}
|
}
|
||||||
this.updateFormValidation()
|
this.updateFormValidation()
|
||||||
},
|
},
|
||||||
|
setInitial (field, value) {
|
||||||
|
this.fieldInitials[field] = value
|
||||||
|
},
|
||||||
update (change) {
|
update (change) {
|
||||||
this.$store.commit(`${this.m}setFieldValue`, Object.assign(change, {
|
this.$store.commit(`${this.m}setFieldValue`, Object.assign(change, {
|
||||||
form: this.name
|
form: this.name
|
||||||
|
@ -294,7 +294,7 @@ export default {
|
|||||||
filter(this.$props, (prop, value) => ['name', 'type', 'id', 'label', 'validation', 'validationLabel'].includes(prop))
|
filter(this.$props, (prop, value) => ['name', 'type', 'id', 'label', 'validation', 'validationLabel'].includes(prop))
|
||||||
)
|
)
|
||||||
if (this.initial !== false) {
|
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