Skip to content

Commit

Permalink
feat: 增加notFilterUndefined配置
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanbo committed Jan 7, 2025
1 parent cd9335c commit 866dd58
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/form-render/api-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ group:
| setValueByPath | 外部修改指定单个 field 的数据(原名 onItemChange) | `(path: Path, value: any) => void` |
| setSchemaByPath | 指定路径修改 schema | `(path: Path, schema: any) => void` |
| setSchema | 指定多个路径修改 schema,cover 传true将直接替换 schema | `({ path: value }, cover?: boolean) => void` |
| getValues | 获取表单内部维护的数据, 如果参数为空则返回当前所有数据 | `(nameList?: Path[], filterFunc?: (meta: { touched: boolean, validating: boolean },isFilterUndefined?:boolean) => boolean) => any` |
| getValues | 获取表单内部维护的数据, 如果参数为空则返回当前所有数据 | `(nameList?: Path[], filterFunc?: (meta: { touched: boolean, validating: boolean }, notFilterUndefined?:boolean) => boolean) => any` |
| getHiddenValues | 获取隐藏的表单数据 | `() => any` |
| getSchema | 获取表单的 schema | `()=> object` |
| removeErrorField | 外部手动删除某一个 path 下所有的校验信息 | `(path: Path) => void` | |
Expand Down
4 changes: 2 additions & 2 deletions packages/form-render/src/models/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ const useForm = () => {
}

// 获取表单数据
xform.getValues = (nameList?: any, filterFunc?: any, isFilterUndefined:boolean=true) => {
xform.getValues = (nameList?: any, filterFunc?: any, notFilterUndefined?:boolean) => {
let values = cloneDeep(form.getFieldsValue(getFieldName(nameList), filterFunc));
const { removeHiddenData } = storeRef.current?.getState() || {};
if (removeHiddenData) {
values = filterValuesHidden(values, flattenSchemaRef.current);
}
if (isFilterUndefined) {
if (!notFilterUndefined) {
values = filterValuesUndefined(values);
}
return parseValuesToBind(values, flattenSchemaRef.current);
Expand Down

0 comments on commit 866dd58

Please sign in to comment.