final-form / final-form/react-final-form

Provide a way to specify a value transformation function applies to the data passed to onSubmit

Open
#971 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.4k
Forks
497
PR merge metrics
No merged PRs in 30d

Description

When asking https://stackoverflow.com/q/70774121/298479 I found another question where a comment (even from @erikras IIRC) suggested storing the "raw" data in the value and converting it only during submission. However, there is no clean way of doing that without keeping fields self-contained. For example, with a date field any "custom" format (e.g. locale-specific) should be handled within the field (the value would always be iso format), and for a number field I may need to deal with strings at first to provide decent validation, but the final data should be a number.

My suggestion is to add something similar to `format` but for the data to be submitted, e.g. `transformValue` or `formatForSubmit` (names aren't amazing but not relevant for now).

That way `format` and `validate` would still have access to the raw data, but form-level validators and onSubmit would receive data in the format the field wants to "output".

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.