Closed TotomInc closed 8 months ago
defineField
is not meant to be used as a store, this is more of useField
job.
However there is a workaround, roughly along these lines:
const [model, props] = defineField('field', (state) => {
return {
props: {
// expose stuff from state here
touched: state.touched,
}
};
});
// Access props
props.value.touched;
What happened?
Using the
defineField()
composable function returned by auseForm()
, I am not able to findmeta
properties for each individual field declared in the form.With
useField()
, it is possible to access meta properties of the current field thanks to:However, I am not able to find a similar API when using
defineField()
, except withform.isFieldValid("firstname")
which causes me to create acomputed()
for each of my fields.I've created a CodeSandbox with 2 components to compare
useField
&defineField
approaches.In the end, it may be useful to create a small convenience API so we can get the
meta
of each fields inside auseForm
like this:Reproduction steps
No response
Version
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://codesandbox.io/p/devbox/epic-haze-hpz6vk
Code of Conduct