Write Clear Usage for understanding #4494
KPlageman-cf
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
https://github.com/logaretm/vee-validate/edit/main/docs/src/pages/api/use-field.mdx
I'd like to see better documentation as to what is happening when using useField, read below the issue I had that a good example would've allowed me to spend less time figuring out what happened.
I had a structure/object of something like {element: value, element: value, etc.} where there was no structure nesting so no {element: { element: value }, element: value, etc.}
Anyways my structure housed my checkbox values not in a nested group, but as siblings to all other data. So when I pass my "initialValue" I thought I could destructure it and it'd assign it to the form's initialValue appropriately. It took me a while to realize it was taking the useField's name I set and adding that as a brand new element to the "initialValue". I have an example below, but by doing it this way it would always be seen as dirty.
Form's initialValue
{name: Cindy, age: 2, cat: false, dog: true, fish: false}
After useField initialValue set
{name: Cindy, age: 2, cat: false, dog: true, fish: false, animalType: {name: Cindy, age: 2, cat: false, dog: true, fish: false}}
It makes sense to me now, though I don't know how to solve my issue, but because I am new to vee-validate and was unable to properly understand the documentation, I believe it should be revisited. My goal in short is for documentation to be easily understood for the next inexperienced person.
Beta Was this translation helpful? Give feedback.
All reactions