vue-form-json-schema
vue-form-json-schema copied to clipboard
uiSchema Error: schema is invalid: data.properties['liquidity'].properties should be object, when model is in an array
I want to create a JSON as following
{ "stock":{ "shops":[ {"location": "high street"}, {"location": "mall"} ] }, "name":"john" }
through normal javascript, I can access the first shop detail with stock.shops[0]
I can put name under model in the uiSchema to correctly link the name (like the following)
component: "div", fieldOptions: { class: ["form-group"], }, children: [ { component: "label", fieldOptions: { attrs: { for: "name-id", }, class: ["font-weight-bold"], domProps: { innerHTML: "Name", }, }, }, { component: "input", model: "name", errorOptions: { class: ["is-invalid"], }, fieldOptions: { attrs: { id: "name-id", }, class: ["form-control"], on: ["input"], }, },
however, putting stock.shops[0] result in the following error
Error: schema is invalid: data.properties['shops'].properties should be object
How should I go about if I want to add an array for shops as shown in my example?
Any chance to create reproduction repo to understand better?
Any chance to create reproduction repo to understand better?
https://codesandbox.io/s/example-1-forked-gdh4w
it is rendering in the sandbox (with error), but in a webpage, it will just crash (not rendering all of uiSchema) error showing: VFJS_EVENT_FIELD_MODEL_VALIDATE schema is invalid: data.properties['liquidity'] should be object,boolean
Hi @HugoKeung
Thanks for the reproduction. I've looked at the sandbox and confirmed the issue and written a patch. I'll release the fix in the next version, v2.9.5. It will be released this weekend.
A fix has been released in v2.9.5 which is available now. Once small caveat however is that the model must be updated to use the dot notation syntax. I.e. instead of liquidity[0][venue] it should be written as liquidity.0.venue.
See a demo here: Demo
Hi @jarvelov , the Demo only display one venue and venue type but empty field value. Is that expected? I have a requirement to create a read only form to display schema containing array eg
{
"success": true,
"result": {
"contactname": "Karina S",
"contactemail": "[email protected]",
"additiondetail": "Test Only",
"requesttype": "New Sim",
"simrequestdetail": [
{
"simserial": "1111111",
"selectedplan": "Voice (High Data)",
"allocation": "Division - C / Group -BC / IT",
"username": "Kari"
},
{
"simserial": "222222",
"selectedplan": "Voice (Low Data)",
"allocation": "Division - C / Group -BC / HR",
"username": "Kari"
}
],
"submissiondate": "Sep 14, 2021, 9:09:31 AM",
"contactnumber": "555 5555",
"type": "S Request",
"deliveryaddress": "Some address",
"status": "Open"
}
}
Was hoping to use your library to make it happen. Thanks.