New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent submit data for file input - inside and outside group input #462
Comments
@justin-schroeder Any thoughts on this? is this expected? |
Hmm, not expected no. Are you seeing that data hit the server when posted? |
I am checking it inside the form submit handler (@submit on FormulateForm) and we are getting that complex object. This happens only if the file input is inside a group. |
I'm having the same issue. Note this bug also occures when the file upload is in a non-repeatable group. @suhasranganath How did you fixed this, or did you find a workaround? Because currently I can't send the form values via Axios because of the complex output. The complex output has endless recursion in it so it can't be converted to JSON and thus i'm not able to send the request at all. |
@Sanderruisseau Sorry for the delayed response. I am picking the required data inside the form submit handler. The complex output object has a property called results and that has the required data. |
I think I had the same issue with the recursion error when using file or image upload within a form (which works outside of a form). Probably the issue is caused by the opinionated approach to have files/image upload via form posting (binary data) which conflicts with the normal operation of the submit handler which uses json data. In my case I just wanted to get (small) images as b64 encoded to include with json post. I resolved this like so: In the form I use file or image (difference in this case is just the preview) with delayed upload:
I set the uploaded file object (!) with setLogo(). Then, in the submit handler, I use a file reader to get the data and convert it to the b64 image data. Note: it is required to delete/overwrite the original object in the formValues (here: name=logoimg), because it is the one which generates the recursion error. I think the documentation could be improved a bit ...
Maybe this could be done more elegant by intercepting submit-raw to load the file and place the result into the formValues. |
Describe the bug
Form submit data for a file input is [{"url": "https://example.com"}] when it's outside a group and
the same will change to a complex object when it is inside a group.
Example complex output:
{
context: (...)
fileList: (...)
files: (...)
input: (...)
options: (...)
results: (...)
supportsDataTransfers: (...)
uploadPromise: (...)
}
Reproduction
CodePen:
https://codepen.io/megamind007/pen/YzVZWjx
Expected behavior
Expected submit data for file input inside group is:
[{name: "sample.png" url: "FILE_URL"}]
but getting
{ context: (...) fileList: (...) files: (...) input: (...) options: (...) results: (...) supportsDataTransfers: (...) uploadPromise: (...) }
The text was updated successfully, but these errors were encountered: