Transform callback gets stale values after first submit #793
Unanswered
Galatex1
asked this question in
Help (React)
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I got into a bit of a pickle with transform() function from form helper. I needed to set one of the fields to a value passed to submit function, but after calling transform, it sets the values correctly the first time, but after for example I get validation errors and then submit it again with different value passed to the submit function, transform function is stale and has the first value only.
For example:
I had two buttons to submit the form and needed each one to set status to different value
I managed to find, that transform is being reassigned to the passed callback and that seemed to be the reason of getting stale values. I was able to customize the hook by keeping transform function as just assignment one and making new variable that holds the callback, which is the used to transform the data.
Changed it from:
To:
I'm not completly sure if what I'm doing here is completly fine or if it could mess with some other things in the hook. Also I could have just used normal Inertia.post() and transformed data before that, but that just didn't feel right to me after using the helper.
Do you guys have any ideas if I might be using the transform wrong or maybe do you think this could be considered bug?
Beta Was this translation helpful? Give feedback.
All reactions