Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit fe58af2e
authored
Nov 17, 2024
by
ryomahan
Committed by
GitHub
Nov 17, 2024
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: form-api.setValues can't resolve nested fields (#4915)
fix #4912
1 parent
94c68c96
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
4 deletions
packages/@core/ui-kit/form-ui/src/form-api.ts
packages/@core/ui-kit/form-ui/src/form-api.ts
View file @
fe58af2
...
...
@@ -13,13 +13,13 @@ import { toRaw } from 'vue';
import
{
Store
}
from
'@vben-core/shared/store'
;
import
{
bindMethods
,
createMerge
,
isFunction
,
isObject
,
mergeWithArrayOverride
,
StateHandler
,
}
from
'@vben-core/shared/utils'
;
import
{
objectPick
}
from
'@vueuse/core'
;
function
getDefaultState
():
VbenFormProps
{
return
{
actionWrapperClass
:
''
,
...
...
@@ -250,8 +250,17 @@ export class FormApi {
form
.
setValues
(
fields
,
shouldValidate
);
return
;
}
const
fieldNames
=
this
.
state
?.
schema
?.
map
((
item
)
=>
item
.
fieldName
)
??
[];
const
filteredFields
=
objectPick
(
fields
,
fieldNames
);
const
fieldMergeFn
=
createMerge
((
obj
,
key
,
value
)
=>
{
if
(
key
in
obj
)
{
obj
[
key
]
=
!
Array
.
isArray
(
obj
[
key
])
&&
isObject
(
obj
[
key
])
?
fieldMergeFn
(
obj
[
key
],
value
)
:
value
;
}
return
true
;
});
const
filteredFields
=
fieldMergeFn
(
fields
,
form
.
values
);
form
.
setValues
(
filteredFields
,
shouldValidate
);
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment