Dynamic form rendering based on value object #11557
Unanswered
andreas-traexler
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a requirement, where I am getting custom form templates from the Zotero API, based on which item type was chosen (e.g. book, software, video, etc.) and the form should be generated with all fields based on what is returned.
Once the form has been rendered, the item type is also part of the form (as a dropdown, since it is also returned as a field in the JSON from the API), so one should be able to switch to a different item type (while the form is already on screen), then the new item type template should get fetched and the form should reset and rerender.
However, react-hook-form does not seem to support said usecase apparently, as can be seen here: #11539 (please note the CSB attached)
The field array always seems to be one "render" behind the exisiting form fields. Additionally, this behavior seems to change based on whether I am using controlled or uncontrolled components.
EDIT: To summarize it in a single sentence: Is it possible to dynamically build a form from a complex JSON object, but also update/remove attributes in the JSON through fields of that same form and have the entire form rebuild itself?
Any help would be greatly appreciated :)
Beta Was this translation helpful? Give feedback.
All reactions