Closed issasami closed 4 years ago
{ "type": "group", "label": "To", "test": { "type": "text", "label": "Test" } },
1) Schema of type 'group' needs a schema property too { type: 'group', schema: { ... } } 2) For deep nested 'group' definitions you must at least define the model structure.
Try this
myModel: {
start: {
to: { },
}
},
mySchema: {
start: {
type: "group",
label: "Start",
schema: {
to: {
type: "group",
label: "To",
schema:{
test: {
type: "text",
label: "Test"
}
}
},
from: {
type: "text",
label: "From"
}
}
}
@wotamann Got it, but if the model is empty? In the case of my project, not all forms have a model (they can be empty), but when I open this form, I want to show a form with empty fields according to the schema and add some information to the fields
I made an update in V 0.2.5 and I think this should work as you expect - see example
Empty Model Object
now a model will be generated even in a deep nested schema-structure, if model is an empty object. model must be an empty plain object and it doesn't work with 'null', 'undefined' or any 'primitive value'. If model is NOT an empty Object, no action is applied, to preserve existing data in model
schema:{ a:{type: "group", schema: { b: [ {c:'text'} ] } } }
then the model structure now will be constructed from schema
model:{} -> model:{ "a": { "b": { "0": {} } } }
Important this works only with model (not with deprecated value)
"vue": "2.6.11", "vuetify": "2.3.4", "vuetify-form-base": "0.1.22",
ERROR
vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in created hook: "No 'model' definition found. Use '<formbase :model="myData" />' "
Schema -
{ "start": { "type": "group", "label": "Start", "schema": { "to": { "type": "group", "label": "To", "test": { "type": "text", "label": "Test" } }, "from": { "type": "text", "label": "From" } } } }
Model -
{ "start": { "from": "some text" } }
In some cases model can be empty or not with all fields.
Thanks for your time.