final-form / react-final-form

🏁 High performance subscription-based form state management for React
https://final-form.org/react
MIT License
7.38k stars 480 forks source link

Empty form values are not included on submit #430

Open ackvf opened 5 years ago

ackvf commented 5 years ago

Are you submitting a bug report or a feature request?

Maybe it is a feature, but I consider it a bug.

What is the current behavior?

Empty form values and pre-selected options are not included in the submit result. Related issue https://github.com/final-form/react-final-form/issues/327

<Field name="favoriteColor" component="select">...</Field>
<Field name="description" component="input" />

// result
{
}

What is the expected behavior?

Expected is that every named field has a value in the result.

// this is the result of direct DOM access to form.elements
{
  favoriteColor: "#ABC",
  description: ""
}

Sandbox Link

Upon opening the sandbox, press "SUBMIT" without entering anything. https://codesandbox.io/s/z66380078l

What's your environment?

Other information

LavaToaster commented 5 years ago

This looks related to #130

prateek3255 commented 4 years ago

Any updates here?

ackvf commented 4 years ago

Would it make sense to merge the actual final-form values to form.elements so that the empty (default) fields are persisted?

remorses commented 4 years ago

It also prevents validation, the validation function passed to useField is not executed

armellarcier commented 4 years ago

796 is related. Actually it’s about the same issue.

TrySpace commented 3 years ago

Quite the catch 22 here https://github.com/final-form/react-final-form/issues/796 https://github.com/final-form/react-final-form/issues/130

eric-ho-github commented 1 year ago

still happening on "final-form": "4.20.7", "react-final-form": "6.5.9",