Ant-design-pro: 关于@Form.create() 怎么在一个组件里面多个不同form

Created on 10 Nov 2017  ·  6Comments  ·  Source: ant-design/ant-design-pro

官方框架上,TableList 上用@Form.create() 可以把两个搜索框的表格关联在一起,现在我想在Modal上获取表格进行校验该怎么解决?

Most helpful comment

+1 同需求。需要在一个route页面里面。使用多个form。

All 6 comments

请尽量不要问用法问题,按 antd issues 的建议,可以到 stackoverflow 或者 segmentfault 上询问具体组件的用法。这里还是尽量讨论 pro 相关的需求和 bug,精力有限,敬请谅解。

个人感觉这个是个BUG,在Modal中的form设定校验规则(不为空)后,在查询的form中规则被同样生效了。

代码如下:

<Card bordered={false}>
<div className={styles.tableList}>
<div className={styles.tableListForm}>
{this.renderForm()}
</div>
</div>
</Card>
<Modal
visible={modalVisible}
onOk={this.handleAdd}
onCancel={() => this.handleModalVisible()}
>
{this.handleModalForm()}
</Modal>

handleModalForm片段如下
<FormItem>
{getFieldDecorator('providerShortname', {
rules: [{ required: true, message: '简称不能为空!' }],
})(<Input placeholder="请输入供卡商简称" />)}
</FormItem>

renderForm片段如下:
<FormItem label="简称">
{getFieldDecorator('providerShortname')(
<Input placeholder="请输入" />
)}
</FormItem>

不要使用重复的 field name

你这只是解决了冲突问题 本质上的bug却还在,不可能所有这种场景都换field name吧

+1 同需求。需要在一个route页面里面。使用多个form。

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cheung1111 picture cheung1111  ·  3Comments

gaoqiang19514 picture gaoqiang19514  ·  3Comments

yadongxie150 picture yadongxie150  ·  3Comments

suifan picture suifan  ·  3Comments

skyFi picture skyFi  ·  3Comments