ant-design-vue icon indicating copy to clipboard operation
ant-design-vue copied to clipboard

validateInfos object is not actual during component init

Open Oleksii14 opened this issue 2 years ago • 4 comments

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.2.5

Environment

Described in the package.json

Reproduction link

https://github.com/Oleksii14/ant-design-form-validation-issue

Steps to reproduce

  1. npm i
  2. npm run dev
  3. open the app in the browser
  4. The form is valid on init, but the validateInfos object is empty so I cannot calculate whether the form is valid initially

Can be fixed by calling validate method from useForm. It will actualize the validateInfos

What is expected?

The validateInfos object should have the actual data (including validateStatus) after component init at once

What is actually happening?

While trying to calculate whether the form is valid or not initially, I noticed that validateInfos object does not contain needed info in the beginning. It is being changed only when starting filling the form


Using the code in the reproduction repo, the current behavior is:

// validateInfos on init

{
name: {autoLink: false, required: false},
lastName: {autoLink: false, required: false}
}

Should be:

// validateInfos on init

{
name: {autoLink: false, required: false, validateStatus: "success"},
lastName: {autoLink: false, required: false, validateStatus: "success"}
}
image

The main question on this issue: Is there a way apart from the approach mentioned in this repo to track the form's validation status? Use case:

const isFormValid = ...

// template
<button :disabled="!isFormValid">submit</button>

Oleksii14 avatar Jun 03 '22 17:06 Oleksii14

I also can't find a way to check if all fields of the form are validated. Hope there is a solution to this problem soon

uitcode avatar Jun 08 '22 03:06 uitcode

there is a third parameter of useForm,not sure if it fits your needs image

xwnwho avatar Jun 08 '22 08:06 xwnwho

there is a third parameter of useForm,not sure if it fits your needs image

Thanks, will check that

Oleksii14 avatar Jun 08 '22 09:06 Oleksii14

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

github-actions[bot] avatar Aug 08 '22 03:08 github-actions[bot]

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Aug 16 '23 00:08 github-actions[bot]