How to preserve value in form when an action got validation errors? #296
Unanswered
armandabric
asked this question in
Q&A
Replies: 2 comments 3 replies
-
Did you find a solution ? |
Beta Was this translation helpful? Give feedback.
3 replies
-
I found out that the input (which is formData) actually preserves the values passed into it! const { execute, result, status, hasErrored, isPending, input } = useStateAction(serverAction, {}); |
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
-
Hey there!
I'm struggling to use
next-safe-action
with a form that could be rejected with validation errors.When the form is submit Next 15 (or React 19?) reset it, and I could not find a way to prevent it to became empty. After a submition that trigger validation errors, the
action.result
entry is only filled with thevalidationErrors
. It seems there is no way to send back the data back like advised now with the reactuseActionState
.I have created a demo to illustrate my problem: https://codesandbox.io/p/devbox/rv6f4c
Is someone have an idea on how to do?
Beta Was this translation helpful? Give feedback.
All reactions