Skip to content
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

Fix application/json with submitSource=dom #377

Merged
merged 3 commits into from
Aug 13, 2024
Merged

Conversation

nick-potts
Copy link
Contributor

fixes #375

Copy link

vercel bot commented Aug 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
remix-validated-form ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 13, 2024 2:31pm
remix-validated-form-docs-v2 ❌ Failed (Inspect) Aug 13, 2024 2:31pm

@nick-potts
Copy link
Contributor Author

I tried writing a test for it, but kept on getting:

Error: Failed to resolve entry for package "@rvf/core". The package may have incorrect main/module/exports specified in its package.json.

Copy link
Owner

@airjp73 airjp73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@@ -107,6 +107,10 @@ export function useForm<FormInputData extends FieldValues, FormOutputData>(
if (!formData)
throw new Error("Missing form data. This is likely a bug in RVF");
if (rvfOpts.id) formData.set(FORM_ID_FIELD_NAME, rvfOpts.id);

if (rvfOpts.encType === "application/json") {
return Object.fromEntries(formData.entries()) as GenericObject;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the right place to change, but this won't handle nested data. You should be able to use preprocessFormData from @rvf/core instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, done

@airjp73
Copy link
Owner

airjp73 commented Aug 13, 2024

I tried writing a test for it, but kept on getting:

Error: Failed to resolve entry for package "@rvf/core". The package may have incorrect main/module/exports specified in its package.json.

For the tests, you need to run bun run build or bun run build-packages (this one is slightly faster) in the root of the package before the tests will run. I should probably document this lol.

@airjp73
Copy link
Owner

airjp73 commented Aug 13, 2024

Thanks!

@airjp73 airjp73 merged commit 26bf688 into airjp73:main Aug 13, 2024
3 checks passed
@airjp73
Copy link
Owner

airjp73 commented Aug 13, 2024

Published as @rvf/[email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: RVF fails to submit dom data when encType is json
2 participants