Hook into the attachement of a nested form and manipulate its components #5222
Closed
jordan-kaxig
started this conversation in
General
Replies: 2 comments
-
Turns out I didn't needed the hooks at all. It was completely ok to manipulate the components with the defaultValue after the form had rendered - and that could be done via form.everyComponent() in combination with Formio.Utils.flattenComponents() in my case. |
Beta Was this translation helpful? Give feedback.
0 replies
-
@jorgen-kaxig glad to hear this worked out, I'm closing this for now but please let us know if you run into any more issues |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We are having a trouble when it comes to presetting the FormIO form with data, as when editing a submission/request. We are not using the FormIO feature where the submissions are stored on their server, but are using our own submit functionality and storage.
Previously we did this by on render of the form setting the form.submission.data object to the stored data, but that triggers some calculated value logic that depends on "onChange" of other fields, resulting in some recalculations of field data that make the form no longer represent the stored data.
So I solved this by setting the component defaultValue properties equal to the stored data fields respectively, before invoking the form definition into the form render function, and it all worked fine.
But for forms that have nested forms it does not work due to their form definition does not exist at render - they are loaded after the render.
I've looked into the hooks attachComponents, addComponent etc, but the components of the nested form does not seem to be there before it is attached, so my manipulation of the "defaultValue" is not manifested in the form.
Does anyone have any experience in this field?
Beta Was this translation helpful? Give feedback.
All reactions