mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-16 01:41:02 +08:00
7a3bf8287f
* chore: bump rc-field-form * docs: Demo driven * refactor: Use event instead * chore: collection logic update * chore: clean up * chore: show warning * chore: warning no need required mark * feat: warning example * docs: mix error * chore: tmp list * chore: magic code * chore: fix motion * chore: fix style * chore: clean up useless code * chore: RM useless import * chore: RM useless file * test: Update snapshot * chore: Should reset * fix: Memo logic * fix: Form basic test case * fix: lint * chore: back of ref * test: Update snapshot * test: RM ueseless test case * chore: RM useless code
1.4 KiB
1.4 KiB
order | title | ||||
---|---|---|---|---|---|
3.2 |
|
zh-CN
rule
添加 warningOnly
后校验不再阻塞表单提交。
en-US
rule
with warningOnly
will not block form submit.
import React from 'react';
import { Form, Input, message, Button, Space } from 'antd';
const Demo = () => {
const [form] = Form.useForm();
const onFinish = () => {
message.success('Submit success!');
};
const onFinishFailed = () => {
message.error('Submit failed!');
};
const onFill = () => {
form.setFieldsValue({
url: 'https://taobao.com/',
});
};
return (
<Form
form={form}
layout="vertical"
onFinish={onFinish}
onFinishFailed={onFinishFailed}
autoComplete="off"
>
<div style={{ overflow: 'hidden' }}>
<Form.Item
name="url"
label="URL"
rules={[
{ required: true },
{ type: 'url', warningOnly: true },
{ type: 'string', min: 6 },
]}
>
<Input placeholder="input placeholder" />
</Form.Item>
</div>
<Form.Item>
<Space>
<Button type="primary" htmlType="submit">
Submit
</Button>
<Button htmlType="button" onClick={onFill}>
Fill
</Button>
</Space>
</Form.Item>
</Form>
);
};
ReactDOM.render(<Demo />, mountNode);