-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Description
- 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 获取 Form的validate 获取已渲染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;
};