Closed Vincz closed 4 years ago
Hi @Vincz , I think Formik automatically touches all fields on submit. So I am not sure if I understand the issue you are facing.
Hey @jannikbuschke ! Thanks for replying.
Indeed, you are right. The problem occurs when the field is not properly initialised with an initial value. (ie. Not set in Formik initialValues
prop). So It's not a problem related to your lib ! Sorry !
Y, I would suggest to always initialise formik values (null is possible I think).
At this line : https://github.com/jannikbuschke/formik-antd/blob/df712fff91bfd3e21ef1f8eb8d7397cbae2da0e1/src/form-item/index.tsx#L30 there is a check to verify if an error must be displayed or not for a given field.
It ensures that the field has been touched before displaying the error. I think it should also check if the form has been submitted or not as it is quite weird to have no error displayed on submit if the field has not been touched. Sometimes, the validation failed because the field is required. Perhaps could it be possible to add a way to define the behaviour with an option ?