@@ -8,6 +8,7 @@ import componentTypes from '../component-types';
8
8
import { prepareArrayValidator , getValidate } from './validator-helpers' ;
9
9
import composeValidators from './compose-validators' ;
10
10
import isEqual from 'lodash/isEqual' ;
11
+ import get from 'lodash/get' ;
11
12
12
13
const calculateInitialValue = ( props ) => {
13
14
if ( Object . prototype . hasOwnProperty . call ( props , 'initialValue' ) && props . dataType ) {
@@ -88,6 +89,10 @@ const useFieldApi = ({ name, resolveProps, skipRegistration = false, ...props })
88
89
const { validatorMapper, formOptions } = useContext ( RendererContext ) ;
89
90
const [ warning , setWarning ] = useState ( ) ;
90
91
92
+ // if there is field initial value, we have to check form initialValues
93
+ // initialValues should have higher priority
94
+ const formInitialValue = Object . prototype . hasOwnProperty . call ( props , 'initialValue' ) ? get ( formOptions . initialValues , name ) : undefined ;
95
+
91
96
const resolvedProps = resolveProps ? resolveProps ( props , createFieldProps ( name , formOptions ) , formOptions ) || { } : { } ;
92
97
93
98
const combinedProps = { ...props , ...resolvedProps } ;
@@ -112,7 +117,7 @@ const useFieldApi = ({ name, resolveProps, skipRegistration = false, ...props })
112
117
...( stateValidate ? { validate : stateValidate } : { } ) ,
113
118
} ;
114
119
115
- const field = useField ( name , enhancedProps ) ;
120
+ const field = useField ( name , { ... enhancedProps , ... ( typeof formInitialValue !== 'undefined' && { initialValue : formInitialValue } ) } ) ;
116
121
117
122
/** Reinitilize type */
118
123
useEffect ( ( ) => {
0 commit comments