Unable to re-render the form for custom changes; each formData update still displays the old data values

“I have FormData which contains an array of objects. Each time the objectId changes, a different object is passed into FormData. However, the newly updated FormData is not reflected in the form.”

const schema = {
“type”: “object”,
“title”: “Visual Assessment Form”,
“required”: ,
“properties”: {
“visual_header”: {
“type”: “object”,
“title”: “--------VISUAL CENTER--------”,
“properties”: {
“visual_presence”: {
“enum”: [“Yes”, “No”],
“type”: “string”,
“title”: “Can you identify the visual center?”,
“segLabel”: “Visual Center”,
“toolMapping”: “brush”
}
}
},
“condition_header”: {
“type”: “object”,
“title”: “--------CONDITION--------”,
“properties”: {
“condition_IRF”: {
“enum”: [“Yes”, “No”, “Ungradable”],
“type”: “string”,
“title”: “Is IRF present?”,
“segLabel”: “IRF”,
“toolMapping”: “brush”
},
“condition_SRF”: {
“enum”: [“Yes”, “No”, “Ungradable”],
“type”: “string”,
“title”: “Is SRF present?”,
“segLabel”: “SRF”,
“toolMapping”: “brush”
}
}
},
“remarks_header”: {
“type”: “object”,
“title”: “”,
“properties”: {
“remarks”: {
“type”: “string”,
“title”: “Additional Remarks”
}
}
},
“assessability_header”: {
“title”: “”,
“properties”: {
“assessability”: {
“enum”: [“Yes”, “No”],
“type”: “string”,
“title”: “Is the Study Assessable?”
}
}
}
},
“description”: “”
}

const uiSchema = {
“visual_header”: { “visual_presence”: { “ui:widget”: “radio” } },
“condition_header”: {
“condition_IRF”: { “ui:widget”: “radio” },
“condition_SRF”: { “ui:widget”: “radio” }
},
“remarks_header”: { “remarks”: { “ui:widget”: “textarea” } },
“assessability_header”: { “assessability”: { “ui:widget”: “radio” } }
}

const formData= [
{ “visual_header”: { “visual_presence”: “Yes” }, “condition_header”: { “condition_IRF”: null, “condition_SRF”: null }, “remarks_header”: { “remarks”: “ere” }, “assessability_header”: { “assessability”: null }, “SectionNumber”: 0 },
{ “visual_header”: { “visual_presence”: null }, “condition_header”: { “condition_IRF”: null, “condition_SRF”: null }, “remarks_header”: { “remarks”: “NEW DATA” }, “assessability_header”: { “assessability”: null }, “SectionNumber”: 1 },
{ “visual_header”: { “visual_presence”: null }, “condition_header”: { “condition_IRF”: “Yes”, “condition_SRF”: null }, “remarks_header”: { “remarks”: “NEW DATA” }, “assessability_header”: { “assessability”: null }, “SectionNumber”: 3 },
]
const CurrentFormData = Formdata[objectId] // objectId is keep changing based on request

I would greatly appreciate it if someone could take a look and provide any insights or suggestions to resolve this issue. If you need any more details or code snippets to understand the problem better, please let me know!

@ sdirix

Whenever you hand in a different object than before as the data prop to JSON Forms, JSON Forms will rerender.

However it seems like that you have custom renderers in place as I’m not familiar with the UI Schema options you are using. You need to make sure that these custom renderers are reacting on data changes with an appropriate rerender. If one of them caches too aggressively, this could be a source of the error.

As an alternative you could also hand over a key set to objectId to JSON Forms. This will force JSON Forms to completely reconstruct with every objectId change and therefore any local caches will be cleared as the corresponding components will be gone.

Which alternative to choose depends on your requirements and use cases.

Hi @sdirix ,Thank you for your previous response. I’ve tried using the key prop, and while the data is being passed correctly, it’s not binding with the form. When handling the onChange event, only the selected values are being captured, and the rest of the formData object is missing. As a result, we are losing the unselected data. Is there another way to handle this?

It’s difficult to debug this from afar. I don’t even know which framework, bindings and renderer sets you are using. Generally speaking, the issue described in the first post should not happen with JSON Forms. So the most likely cause is an issue in how JSON Forms is used or a bug in a custom renderer.

All of this sounds very unusual. Without your code I’m not able to help you.