File tree 2 files changed +5
-3
lines changed
2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change 1
1
import type { ExtractPropTypes , InjectionKey , PropType , Ref } from 'vue' ;
2
- import { inject , provide } from 'vue' ;
2
+ import { computed , inject , provide } from 'vue' ;
3
3
import type { ValidateMessages } from '../form/interface' ;
4
4
import type { RequiredMark } from '../form/Form' ;
5
5
import type { RenderEmptyHandler } from './renderEmpty' ;
@@ -17,7 +17,7 @@ export const useProvideGlobalForm = (state: GlobalFormCOntextProps) => {
17
17
} ;
18
18
19
19
export const useInjectGlobalForm = ( ) => {
20
- return inject ( GlobalFormContextKey , { } ) ;
20
+ return inject ( GlobalFormContextKey , { validateMessages : computed ( ( ) => undefined ) } ) ;
21
21
} ;
22
22
23
23
export const GlobalConfigContextKey : InjectionKey < GlobalFormCOntextProps > =
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ import useConfigInject from '../_util/hooks/useConfigInject';
30
30
import { useProvideForm } from './context' ;
31
31
import type { SizeType } from '../config-provider' ;
32
32
import useForm from './useForm' ;
33
+ import { useInjectGlobalForm } from '../config-provider/context' ;
33
34
34
35
export type RequiredMark = boolean | 'optional' ;
35
36
export type FormLayout = 'horizontal' | 'inline' | 'vertical' ;
@@ -127,10 +128,11 @@ const Form = defineComponent({
127
128
return true ;
128
129
} ) ;
129
130
const mergedColon = computed ( ( ) => props . colon ?? contextForm . value ?. colon ) ;
131
+ const { validateMessages : globalValidateMessages } = useInjectGlobalForm ( ) ;
130
132
const validateMessages = computed ( ( ) => {
131
133
return {
132
134
...defaultValidateMessages ,
133
- ...contextForm . value ?. validateMessages ,
135
+ ...globalValidateMessages . value ,
134
136
...props . validateMessages ,
135
137
} ;
136
138
} ) ;
You can’t perform that action at this time.
0 commit comments