Closed namti closed 1 year ago
I am closing the issue as it was created too long ago and there is no new comments here. If the issue is not resolved, please reopen it. Thanks!
Please reopen this issue. I am also getting the same issue. I am not able to pre-populate data on fields even after i tried to update the component data while providing it to the Rorm component to fillup the defaultValue .
Functions I used to update the component:
function fillupDefaultValues(component, prefillData) {
let result;
if (component.components) {
result = component.components.map((comp) =>
fillupDefaultValues(comp, prefillData),
);
return { ...component, components: result };
} else if (component.columns) {
result = component.columns.map((comp) =>
fillupDefaultValues(comp, prefillData),
);
return { ...component, columns: result };
} else {
if (prefillData[component.key]) {
result = { ...component, defaultValue: prefillData[component.key] };
} else {
result = { ...component };
}
return result;
}
}
const prefillData = (components, prefillData) => {
if (!prefillData) {
return components;
}
const data = components.map((component) => {
return fillupDefaultValues(component, prefillData);
});
return data;
};
Used it as:
<Form form={{
components: prefillData(components, prefillData),
}}
onChange={(changedData) => changeFormData(changedData)}
/>
please suggest some solution to acheve it
Environment
Please provide as many details as you can:
Steps to Reproduce
Expected behavior
Observed behavior
If submission and onChange event are put together, the
<Form />
creates infinite loop. It re-renders all elements and slows down the performanceExample
If possible, please provide a screenshot, live example (via JSFiddle or similar), and/or example code to help demonstrate the issue.
For code or form JSON, please enclose in a code block:
form.json