1
0
mirror of synced 2025-02-16 20:53:13 +03:00

Makes value set the initial value of inputs

This commit is contained in:
Justin Schroeder 2020-01-31 22:50:18 -05:00
parent 6954b45867
commit 778d6b8731
6 changed files with 14 additions and 5 deletions

View File

@ -1272,7 +1272,7 @@ var script = {
*/
defaultId: nanoid(9),
localAttributes: {},
internalModelProxy: this.formulateValue,
internalModelProxy: this.formulateValue || this.value,
behavioralErrorVisibility: (this.errorBehavior === 'live'),
formShouldShowErrors: false,
validationErrors: [],

View File

@ -1275,7 +1275,7 @@ var Formulate = (function (exports, isUrl, nanoid, isPlainObject) {
*/
defaultId: nanoid(9),
localAttributes: {},
internalModelProxy: this.formulateValue,
internalModelProxy: this.formulateValue || this.value,
behavioralErrorVisibility: (this.errorBehavior === 'live'),
formShouldShowErrors: false,
validationErrors: [],

View File

@ -1278,7 +1278,7 @@
*/
defaultId: nanoid(9),
localAttributes: {},
internalModelProxy: this.formulateValue,
internalModelProxy: this.formulateValue || this.value,
behavioralErrorVisibility: (this.errorBehavior === 'live'),
formShouldShowErrors: false,
validationErrors: [],

View File

@ -5,7 +5,6 @@
"main": "dist/formulate.umd.js",
"module": "dist/formulate.esm.js",
"unpkg": "dist/formulate.min.js",
"private": true,
"engines": {
"node": ">=11"
},

View File

@ -170,7 +170,7 @@ export default {
*/
defaultId: nanoid(9),
localAttributes: {},
internalModelProxy: this.formulateValue,
internalModelProxy: this.formulateValue || this.value,
behavioralErrorVisibility: (this.errorBehavior === 'live'),
formShouldShowErrors: false,
validationErrors: [],

View File

@ -143,6 +143,16 @@ describe('FormulateInputText', () => {
expect(wrapper.find('input').element.value).toBe('initial val')
})
it('uses the value as the initial value', () => {
const wrapper = mount(FormulateInput, { propsData: { type: 'text', value: 'initial val' } })
expect(wrapper.find('input').element.value).toBe('initial val')
})
it('uses the v-model value as the initial value when value prop is provided', () => {
const wrapper = mount(FormulateInput, { propsData: { type: 'text', formulateValue: 'initial val', value: 'initial other val' } })
expect(wrapper.find('input').element.value).toBe('initial val')
})
it('uses a proxy model internally if it doesnt have a v-model', () => {
const wrapper = mount(FormulateInput, { propsData: { type: 'textarea' } })
const input = wrapper.find('textarea')