@@ -7,7 +7,7 @@ import type { ExtendedFormApi, FormActions, VbenFormProps } from './types';
7
7
import { computed , unref , useSlots } from 'vue' ;
8
8
9
9
import { createContext } from '@vben-core/shadcn-ui' ;
10
- import { isString } from '@vben-core/shared/utils' ;
10
+ import { isString , mergeWithArrayOverride , set } from '@vben-core/shared/utils' ;
11
11
12
12
import { useForm } from 'vee-validate' ;
13
13
import { object } from 'zod' ;
@@ -50,15 +50,19 @@ export function useFormInitial(
50
50
const zodObject : ZodRawShape = { } ;
51
51
( unref ( props ) . schema || [ ] ) . forEach ( ( item ) => {
52
52
if ( Reflect . has ( item , 'defaultValue' ) ) {
53
- initialValues [ item . fieldName ] = item . defaultValue ;
53
+ set ( initialValues , item . fieldName , item . defaultValue ) ;
54
54
} else if ( item . rules && ! isString ( item . rules ) ) {
55
55
zodObject [ item . fieldName ] = item . rules ;
56
56
}
57
57
} ) ;
58
58
59
59
const schemaInitialValues = getDefaultsForSchema ( object ( zodObject ) ) ;
60
60
61
- return { ...initialValues , ...schemaInitialValues } ;
61
+ const zodDefaults : Record < string , any > = { } ;
62
+ for ( const key in schemaInitialValues ) {
63
+ set ( zodDefaults , key , schemaInitialValues [ key ] ) ;
64
+ }
65
+ return mergeWithArrayOverride ( initialValues , zodDefaults ) ;
62
66
}
63
67
64
68
return {
0 commit comments