-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isFieldDirty on array of object field #4575
Comments
A const { dirtyFields } = useForm() would be lovely! |
This is a technicality issue, This is a quick win, so I will work on it. @Acetyld that's a good suggestion but more complex because of the nature of paths vs fields, you can find a discussion on that here #4593 |
ooh ok, i got it. thank you |
One more question @logaretm. Let say, I have 1 more field namely |
What happened?
I'm using field array, and I want to check if a specific field is dirty using
isFieldDirty
. It worked properly on basic field, but it's not as I expected when it used on array field.Here I forked the field array example stackblitz and modify it to use
isFieldDirty
.So, when I change a field that part of the array field, the dirty flag from the meta is true (work as expected). But the dirty flag from
isFieldDirty('users')
resulted as false, isn't should be true as well? Because the fieldusers
value has been changed and the dirty flag from meta is true thoBut, when I check the field array to the specific index and field like
isFieldDirty('users[0].name')
, it resulted true. Why when the path is refer to the field array name is not resulted as expected, compared with specific index path?Or may be is there a function or prop that return the dirty field? For example
const { dirtyFields } = useForm()
, that will be return the dirty field's name like{'users'}
Also i got question for the similar issue with this one on #3448, related to initialValue that affected from conditional rendering, so the dirty flag is not accurate anymore
Reproduction steps
Stackblitz link: https://stackblitz.com/edit/vee-validate-v4-array-fields-n33ulm?file=src%2FApp.vue
Step:
isFieldDirty('users')
would be true, actual: it is still false, but themeta.dirty
of the form is trueVersion
Vue.js 3.x and vee-validate 4.x
What browsers are you seeing the problem on?
Relevant log output
No response
Demo link
https://stackblitz.com/edit/vee-validate-v4-array-fields-n33ulm?file=src%2FApp.vue
Code of Conduct
The text was updated successfully, but these errors were encountered: