File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change 11import type { ExtractPropTypes , InjectionKey , PropType , Ref } from 'vue' ;
2- import { inject , provide } from 'vue' ;
2+ import { computed , inject , provide } from 'vue' ;
33import type { ValidateMessages } from '../form/interface' ;
44import type { RequiredMark } from '../form/Form' ;
55import type { RenderEmptyHandler } from './renderEmpty' ;
@@ -17,7 +17,7 @@ export const useProvideGlobalForm = (state: GlobalFormCOntextProps) => {
1717} ;
1818
1919export const useInjectGlobalForm = ( ) => {
20- return inject ( GlobalFormContextKey , { } ) ;
20+ return inject ( GlobalFormContextKey , { validateMessages : computed ( ( ) => undefined ) } ) ;
2121} ;
2222
2323export const GlobalConfigContextKey : InjectionKey < GlobalFormCOntextProps > =
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ import useConfigInject from '../_util/hooks/useConfigInject';
3030import { useProvideForm } from './context' ;
3131import type { SizeType } from '../config-provider' ;
3232import useForm from './useForm' ;
33+ import { useInjectGlobalForm } from '../config-provider/context' ;
3334
3435export type RequiredMark = boolean | 'optional' ;
3536export type FormLayout = 'horizontal' | 'inline' | 'vertical' ;
@@ -127,10 +128,11 @@ const Form = defineComponent({
127128 return true ;
128129 } ) ;
129130 const mergedColon = computed ( ( ) => props . colon ?? contextForm . value ?. colon ) ;
131+ const { validateMessages : globalValidateMessages } = useInjectGlobalForm ( ) ;
130132 const validateMessages = computed ( ( ) => {
131133 return {
132134 ...defaultValidateMessages ,
133- ...contextForm . value ?. validateMessages ,
135+ ...globalValidateMessages . value ,
134136 ...props . validateMessages ,
135137 } ;
136138 } ) ;
You can’t perform that action at this time.
0 commit comments