diff --git a/packages/core/src/form/useFormField.ts b/packages/core/src/form/useFormField.ts index 7c933388..1a355666 100644 --- a/packages/core/src/form/useFormField.ts +++ b/packages/core/src/form/useFormField.ts @@ -41,7 +41,7 @@ export function useFormField(opts?: Partial toValue(opts?.path); const { fieldValue, pathlessValue, setValue } = useFieldValue(getPath, form, opts?.initialValue); const { isTouched, pathlessTouched, setTouched } = useFieldTouched(getPath, form); - const { errors, setErrors, isValid, errorMessage } = useFieldValidity(getPath, form); + const { errors, setErrors, isValid, errorMessage, pathlessValidity } = useFieldValidity(getPath, form); const isDirty = computed(() => { if (!form) { @@ -124,7 +124,7 @@ export function useFormField(opts?: Partial, form: FormCon const isTouched = computed(() => { const path = getPath(); - return path ? form.isFieldTouched(path) : false; + return path ? form.isFieldTouched(path) : pathlessTouched.value; }) as Ref; function setTouched(value: boolean) { @@ -293,6 +293,7 @@ function createFormValidityRef(getPath: Getter, form: FormCo } return { + pathlessValidity, errors, setErrors, }; @@ -301,10 +302,15 @@ function createFormValidityRef(getPath: Getter, form: FormCo function createLocalValidity() { const errors = shallowRef([]); - return { + const api = { errors, setErrors(messages: Arrayable) { errors.value = messages ? normalizeArrayable(messages) : []; }, }; + + return { + pathlessValidity: api, + ...api, + }; } diff --git a/packages/playground/src/App.vue b/packages/playground/src/App.vue index 772b9e62..ba007b65 100644 --- a/packages/playground/src/App.vue +++ b/packages/playground/src/App.vue @@ -2,12 +2,7 @@
- +