Yes, it is possible to create a nested dynamic form using ant design dynamic form component.(是的,可以使用ant design动态表单组件创建嵌套的动态表单。)
I have also asked the same question How to create a questionnaire type form using Ant Design?(我也曾问过同样的问题如何使用Ant Design创建问卷类型表格?) .(。) You need to add your own logic but here I am providing the basic structure:(您需要添加自己的逻辑,但是在这里,我提供了基本结构:)
To remove team name:(删除团队名称:)
remove = k => {
const { form } = this.props;
const keys = form.getFieldValue("newkeys");
form.setFieldsValue({
newkeys: keys.filter(key => key !== k)
});
};
To add team name:(要添加团队名称:)
add = () => {
const { form } = this.props;
const keys = form.getFieldValue("newkeys");
const nextKeys = keys.concat(uuid);
uuid++;
form.setFieldsValue({
newkeys: nextKeys
});
};
To remove team member:(删除团队成员:)
remove1 = (k, l) => {
const { form } = this.props;
const keys = form.getFieldValue("answerkey" + k);
let newkeys = [];
if (keys) {
newkeys = keys;
} else {
newkeys = [];
}
form.setFieldsValue({
["answerkey" + k]: newkeys.filter(key => key !== l)
});
};
To add team member:(要添加团队成员:)
add1 = index => {
const { form } = this.props;
const keys = form.getFieldValue("answerkey" + index);
let newkeys = [];
if (keys) {
newkeys = keys;
} else {
newkeys = [];
}
const nextKeys = newkeys.concat(uuid1);
uuid1++;
form.setFieldsValue({
["answerkey" + index]: nextKeys
});
};
I have created a working demo on codesandbox.io .(我已经在codeandbox.io上创建了一个工作演示。) 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…