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
当destroyOnClose为true时,openModal方法中setFieldsValue无效,请问应该怎么处理才会生效
点用openModal方法时传入value
表单被赋值
import React, { useState, useImperativeHandle, useRef } from 'react'; import { ModalForm, ProFormText, ProFormSelect, ProFormTextArea } from '@ant-design/pro-form'; export default React.forwardRef(function ProjectForm(props, ref) { const [type, setType] = useState(''); const [visible, setVisible] = useState(false); const formRef = useRef(); const onFinish = async (values) => { return await props?.onFinish(type, values); }; useImperativeHandle(ref, () => { return { openModal: (type, values) => { setVisible(true); setType(type); const form = formRef.current; if (type === 'edit') { console.log(form, values); form?.setFieldsValue(values); } // form?.setFieldsValue({ user: [{ value: 1, label: 'xxxx' }] }); }, }; }); return ( <ModalForm formRef={formRef} title={type === 'add' ? '新增' : '修改'} visible={visible} onVisibleChange={setVisible} onFinish={onFinish} modalProps={{ destroyOnClose: true }} > <ProFormText label="项目名称" name="name1" /> <ProFormText label="项目简称" name="name" /> </ModalForm> ); });
"@ant-design/pro-form@^1.31.2": version "1.32.1"
The text was updated successfully, but these errors were encountered:
Sorry, something went wrong.
看你的示例看起来是在设置表单的初始值,为什么不尝试使用initialValues属性呢?
看你的示例看起来是在设置表单的初始值,为什么不尝试使用initialValues属性呢? @kiner-tang 这个组件会被多次打开,当type为add时我需要重置表单,为edit时设置value,请问应该怎么处理呢
是我的bug,因为关闭的时候form 没了。我排查下为什么
修复了。因为触发了重新set
No branches or pull requests
🐛 bug 描述
当destroyOnClose为true时,openModal方法中setFieldsValue无效,请问应该怎么处理才会生效
📷 复现步骤
点用openModal方法时传入value
🏞 期望结果
表单被赋值
💻 复现代码
© 版本信息
"@ant-design/pro-form@^1.31.2": version "1.32.1"
🚑 其他信息
The text was updated successfully, but these errors were encountered: