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

<Field> with InitialValue displays required validation error #658

Open acejusto11 opened 4 years ago

acejusto11 commented 4 years ago

Are you submitting a bug report or a feature request?

Bug report

What is the current behavior?

When componentDidMount() has no implementation, the form displays 'required' error message for required input even if initialValue is set to Field component; thus, form can't also be submitted,

What is the expected behavior?

No 'required' validation message should be displayed and form can be submitted.

Sandbox Link

Steps to reproduce: https://codesandbox.io/s/react-final-form-simple-example-2l600

  1. On the sandbox, comment the codes in componentDidMount()
  2. Click the submit button.

Result:

  1. 'Required' message appears
  2. Form cannot be submitted

What's your environment?

React-final-form: latest Final Form: latest OS: Windows Browser: Chrome Node JS: 10.15.3

lookfirst commented 4 years ago

I'd set the initialValues on the <Form> not on the <Field> element... this seems to work just fine...

https://codesandbox.io/s/react-final-form-simple-example-lfxwt