Any way to only submit values that are present in the form?
See original GitHub issueQuestion/Feature
I have a redux store that keeps a couple of hundred settings. Of those I only want to display 10-20 in the form. No problem so far. But when I submit the form, all values are submitted, not only those present in the form (the values with an input field).
I suppose I could pick just the values I need from the store state in mapPropsToValues
, but it seems like duplicated work.
Is there any better way to handle this?
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
How can I get all a form's values that would be submitted ...
Get the data from the form by using FormData objects. var formData = new FormData(formEl);. Get the value of the fields by the...
Read more ><input type="submit"> - HTML: HyperText Markup Language
A string indicating the HTTP method to use when submitting the form's data; this value overrides any method attribute given on the owning...
Read more >How to add Hidden Fields to your Google Form - YouTube
Using hidden fields is a great way to set default values within a form submission to make it easier for you to organize...
Read more >Show form questions based on answers - Google Support
Go to section based on answer. Next to each answer, click the Down arrow "" to choose where to send people.
Read more >.submit() | jQuery API Documentation
The submit event is sent to an element when the user is attempting to submit a form. It can only be attached to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jomag If you wanna limit fields, you can use
yup
for this. I do it for highly dynamic forms, usingwhen
like @latviancoder mentioned, but also somehow I abuseyup.validate
withstripUnknown: true
- https://github.com/jquense/yup#mixedvalidatevalue-any-options-object-promiseany-validationerrorAnother trick I use is
const initialValues = schema.cast()
, which can give me default values of aschema
.My point is, for me
yup
is a logic/validation layer,Formik
is a view layer, each one has its own responsibility.Seems like this has been resolved. Would be great to add it to docs section on validation. @klis87 May hit you up on Twitter about your technique so I can add as a docs example