Using parseWithZod with a formData that has an array of strings #727
-
Describe the bug and the expected behaviorim sending an array of strings trough the network using formData with a value: but when looking at the outcome of: im seeing that it doesnt parse the array corretly, it looks like this: What you can see here is an array that his first value is a stringify Array. instead of just array of values Conform version"@conform-to/react": "^1.1.5" Steps to Reproduce the Bug or Issuetry to use parseWithZod on a formData with an array What browsers are you seeing the problem on?No response Screenshots or VideosNo response Additional contextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
What's your specific use-case? Why do you set formData like this imperatively on the formData object? Just trying to understand because the result is what I had expected from looking at the example. 🤔 From my understand, with FormData array values are usually transformed to comma separated strings, e.g.: const formData = new FormData();
formData.set("classifications", ["foo", "bar"])would lead to a key value pair of: ["classifications", "foo, bar"] |
Beta Was this translation helpful? Give feedback.
-
|
I guess you are looking for formData.append() which could be used like this: formData.append('classifications', 'foo');
formData.append('classifications', 'bar');
formData.append('classifications', 'baz'); |
Beta Was this translation helpful? Give feedback.
I guess you are looking for formData.append() which could be used like this: