Skip to content

Form.useForm hopes to add the from parameter to get the active field #5795

@luocong2016

Description

@luocong2016
  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

Form.useForm 希望可以加入 from 参数, 获取哪些是当前Form 表单激活状态(包括隐藏,不包含渲染)的字段。
比如: 通过 ref 获取 Formvalidate 获取已渲染DOM字段的有效值

<Form form={form} />

What does the proposed API look like?

/*
modelRef, ruleRef` 必须是响应式数据
*/

interface Props {
[key: string]: any;
}
function useForm(
modelRef: Props | Ref,
rulesRef?: Props | Ref,
options?: {
form?: xxx;
immediate?: boolean;
deep?: boolean;
validateOnRuleChange?: boolean;
debounce?: DebounceSettings;
},
form?: xxx
): {
form: xxx;
getActivetFieldValues: xxxx;
modelRef: Props | Ref;
rulesRef: Props | Ref;
initialModel: Props;
validateInfos: validateInfos;
resetFields: (newValues?: Props) => void;
validate: <T = any>(names?: namesType, option?: validateOptions) => Promise;
validateField: (
name?: string,
value?: any,
rules?: [Record<string, unknown>],
option?: validateOptions,
) => Promise<RuleError[]>;
mergeValidateInfo: (items: ValidateInfo | ValidateInfo[]) => ValidateInfo;
clearValidate: (names?: namesType) => void;
onValidate?: (
name: string | number | string[] | number[],
status: boolean,
errorMsgs: string[] | null,
) => void;
};

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions