Skip to content

Commit e6d2fd7

Browse files
authoredFeb 19, 2025··
Merge pull request #1627 from alibaba/form-render-getvalues-all-data
fix:getValues增加参数,notFilterHideData,不过滤掉hidden:true的数据
2 parents 041bdb6 + d37d99c commit e6d2fd7

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed
 

‎docs/form-render/api-props.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ group:
4848
| setValueByPath | 外部修改指定单个 field 的数据(原名 onItemChange) | `(path: Path, value: any) => void` |
4949
| setSchemaByPath | 指定路径修改 schema | `(path: Path, schema: any) => void` |
5050
| setSchema | 指定多个路径修改 schema,cover 传true将直接替换 schema | `({ path: value }, cover?: boolean) => void` |
51-
| getValues | 获取表单内部维护的数据, 如果参数为空则返回当前所有数据 | `(nameList?: Path[], filterFunc?: (meta: { touched: boolean, validating: boolean }, notFilterUndefined?:boolean) => boolean) => any` |
51+
| getValues | 获取表单内部维护的数据, 如果参数为空则返回当前所有数据 | `(nameList?: Path[], filterFunc?: (meta: { touched: boolean, validating: boolean }, notFilterUndefined?:boolean,notFilterHideData?:boolean) => boolean) => any` |
5252
| getHiddenValues | 获取隐藏的表单数据 | `() => any` |
5353
| getSchema | 获取表单的 schema | `()=> object` |
5454
| removeErrorField | 外部手动删除某一个 path 下所有的校验信息 | `(path: Path) => void` | |

‎packages/form-render/src/models/useForm.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ const useForm = () => {
163163
}
164164

165165
// 获取表单数据
166-
xform.getValues = (nameList?: any, filterFunc?: any, notFilterUndefined?:boolean) => {
166+
xform.getValues = (nameList?: any, filterFunc?: any, notFilterUndefined?:boolean,notFilterHideData:boolean=true) => {
167167
let values = cloneDeep(form.getFieldsValue(getFieldName(nameList), filterFunc));
168168
const { removeHiddenData } = storeRef.current?.getState() || {};
169-
if (removeHiddenData) {
169+
if (notFilterHideData && removeHiddenData) {
170170
values = filterValuesHidden(values, flattenSchemaRef.current);
171171
}
172172
if (!notFilterUndefined) {

0 commit comments

Comments
 (0)
Please sign in to comment.