We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
提问前先看看:
https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md
ProFormDependency, FormListContext
让ProFormDependency支持跨Form组件,主要是在FormListContext中增加一个rootPath之类的字段,让Dependency可以获取到外部Form的path
自定义组件中使用到了form form.list,并且为了更好的符合pro-components的规范,想和ProFormList类似只传需要的业务字段
例:ProFormRuleTree的内部状态是通过一个Form管理的,这导致Dependency和Form.Item取到的name是一样的,但是Form.Item需要相对内部的Form,Dependency是需要相对外部的Form(这是由于Dependency的现有代码逻辑决定的,因此想加一个字段做判断)
ProFormRuleTree的部分伪代码,内部通过FormListContext来修改了listName,可以避免用户侧拼接props.path, index
<Form components={false}> {...} <Form> <RuleItem> <FormListContext.Provider value={{ name: [index], + rootPath, + listName: [...props.path, index], - listName: [...rootPath, ...props.path, index], }} > {children} </FormListContext.Provider> </RuleItem>
业务代码
<ProForm> // ---> outter form <ProFormRuleTree // ---> inner form name={'ruleTree'} > <Space> <ProFormText noStyle name={'name'} /> <ProFormDependency name={['name']}> { (record) => { console.log(record); return <Tag>{record.name}</Tag>; } } </ProFormDependency> </Space> </ProFormRuleTree> <ProForm>
FormListContext添加一个字段,比如rootName。如果字段存在则优先把rootName拼接上
// https://github.com/hans000/pro-components/blob/master/packages/form/src/components/Dependency/index.tsx#L83 - const itemName = flattenNames[i] + const itemName = formListField.rootName ? [...formListField.rootName, flattenNames[i]] : flattenNames[i];
The text was updated successfully, but these errors were encountered:
暂时不需要了
Sorry, something went wrong.
No branches or pull requests
提问前先看看:
https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md
🔩 所属模块或组件
ProFormDependency, FormListContext
🥰 需求描述
让ProFormDependency支持跨Form组件,主要是在FormListContext中增加一个rootPath之类的字段,让Dependency可以获取到外部Form的path
⛰ 功能需求适用场景
自定义组件中使用到了form form.list,并且为了更好的符合pro-components的规范,想和ProFormList类似只传需要的业务字段
例:ProFormRuleTree的内部状态是通过一个Form管理的,这导致Dependency和Form.Item取到的name是一样的,但是Form.Item需要相对内部的Form,Dependency是需要相对外部的Form(这是由于Dependency的现有代码逻辑决定的,因此想加一个字段做判断)
ProFormRuleTree的部分伪代码,内部通过FormListContext来修改了listName,可以避免用户侧拼接props.path, index
业务代码
🧐 解决方案
FormListContext添加一个字段,比如rootName。如果字段存在则优先把rootName拼接上
🚑 其他信息
The text was updated successfully, but these errors were encountered: