ant-design-vue
ant-design-vue copied to clipboard
validateInfos object is not actual during component init
- [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
- npm i
- npm run dev
- open the app in the browser
- 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"}
}

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>
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
there is a third parameter of useForm,not sure if it fits your needs
there is a third parameter of useForm,not sure if it fits your needs
Thanks, will check that
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
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.