Skip to content

Commit aeb700a

Browse files
committed
Allow configuration of the prop which the model gets passed to.
Previously the model was passed to 'value' without anyway to change it, but now it can be defined using the property `valueProp` on the root of the field, or setting the property in the options prop to the vue-form-json-schema component.
1 parent 1ba9f78 commit aeb700a

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

src/vfjs-component/methods/getters.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ const getters = {
5454
key: this.vfjsFieldId,
5555
};
5656

57+
const valueProp = {
58+
[this.vfjsFieldValueProp]: this.vfjsFieldModel,
59+
};
60+
5761
const allAttributes = merge(
5862
{},
5963
key,
@@ -62,6 +66,7 @@ const getters = {
6266
fieldOptionsAsProps,
6367
options,
6468
computedOptions,
69+
valueProp,
6570
);
6671

6772
return allAttributes;

src/vfjs-component/props.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ const props = {
6161
type: Object,
6262
required: true,
6363
},
64+
vfjsFieldValueProp: {
65+
type: String,
66+
},
6467
vfjsOptions: {
6568
type: Object,
6669
required: true,

src/vfjs-global/data.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const data = () => ({
4141
validate: true,
4242
validateOnLoad: true,
4343
validateOnChange: true,
44+
valueProp: 'value',
4445
},
4546
vfjsSchema: {},
4647
vfjsState: {},

src/vfjs-global/methods/vfjs-helpers/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const vfjsHelpers = {
1212
fieldOptions: vfjsFieldOptions = {},
1313
model: vfjsFieldModelKey = '',
1414
required: vfjsFieldRequired = false,
15+
valueProp: vfjsFieldValueProp = this.vfjsOptions.valueProp,
1516
} = vfjsFieldUiSchema;
1617

1718
const vfjsFieldSchema = this.getVfjsFieldSchema(vfjsFieldModelKey) || {};
@@ -48,6 +49,7 @@ const vfjsHelpers = {
4849
vfjsFieldSchemas,
4950
vfjsFieldState,
5051
vfjsFieldUiSchema,
52+
vfjsFieldValueProp,
5153
vfjsOptions: this.vfjsOptions,
5254
vfjsModel,
5355
vfjsState,

0 commit comments

Comments
 (0)