react-jsonschema-form
react-jsonschema-form copied to clipboard
Issue with omit extra data and live omit not working onSubmit
Prerequisites
- [X] I have read the documentation
What theme are you using?
bootstrap-4
What is your question?
I'm encountering an issue with the React JSON Form library where omit and liveOmit functionality seems to be working only on onChange but not on onSubmit, particularly when the user proceeds to submit the form without making any changes. When I use omit or liveOmit to exclude certain fields from the form submission, it behaves as expected during user interaction (onChange), but the omitted fields still get submitted when the form is submitted (onSubmit) without any user modifications.
Is there a known workaround or configuration setting to ensure that omitted fields are also excluded from the final form submission (onSubmit) in cases where the user hasn't made any changes? Alternatively, is there a recommended approach to achieve omitting fields specifically on form submission?
Here's how you can replicate the issue in react playground:
- Navigate to the React JSON Form playground.
- In the JSON schema, add a field called "foo" with a default value of "bar".
- Check the "Omit extra data" and "Live omit" options.
- Observe that the "foo" field is included in the form.
- Without making any changes to the form fields, click the "Submit" button.
- Notice that despite the "Omit extra data" and "Live omit" options being checked, the "foo" field is still included in the submitted data.
- If you now make any changes to the form, foo should get removed.
Any insights or guidance on resolving this issue would be greatly appreciated!
@AayushB This may be a duplicate of #4109. I know that there are several people possibly working on a solution to that bug.
Thank you for linking to me the related issue. I found the link very helpful, but needed an immediate fix. Given this, the solution we have come in the interim is to use a custom Widget that calls onChange with the desired data when the component is loaded.