Forms example
#1329
Replies: 1 comment 2 replies
-
|
Hey @Aman-Anas! Thanks for sharing 👐 I think that could work! Another option is that, since in the editor you wouldn’t necessarily need to submit the form, you could use your Puck prop as the field’s Does that make sense? |
Beta Was this translation helpful? Give feedback.
2 replies
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.
-
Hi, this is a great library and I'm enjoying the flexibility of the project. Documentation is also great.
I was able to create a form builder tool using Puck, shadcn, and the react-hook-forms library. Basically I just have a react-hook-form
<FormProvider>wrapping all the actual form element children, which I can then just make Puck components for and it works almost perfectly.There are some quirks with "default values" and setting them up as props.
I ended up adding a useEffect trigger like this into the render function, so it would update the form's value with the initial state prop while the component is in the "editor" mode, and once the user has entered some real data in a
<Render>, I can usereact-hook-form's submit functionality to "save" the state and pass it back in via the metadata field.It seems to work, so I just wanted to share this use case. I'm also not sure if this is the best way to do things, so maybe an example could be added in the docs.
Beta Was this translation helpful? Give feedback.
All reactions