forked from ant-design/ant-design
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Update batch of docs & demos (ant-design#44509)
* docs: update select opt * docs: update form deps demo * docs: upload onChange * docs: update form nest Form.List demo
- Loading branch information
Showing
15 changed files
with
622 additions
and
475 deletions.
There are no files selected for viewing
455 changes: 243 additions & 212 deletions
455
components/form/__tests__/__snapshots__/demo-extend.test.ts.snap
Large diffs are not rendered by default.
Oops, something went wrong.
371 changes: 238 additions & 133 deletions
371
components/form/__tests__/__snapshots__/demo.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## zh-CN | ||
|
||
Form.Item 可以通过 `dependencies` 属性,设置关联字段。当关联字段的值发生变化时,会触发校验与更新。 | ||
|
||
## en-US | ||
|
||
Form.Item can set the associated field through the `dependencies` property. When the value of the associated field changes, the validation and update will be triggered. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React from 'react'; | ||
import { Alert, Form, Input, Typography } from 'antd'; | ||
|
||
const App: React.FC = () => { | ||
const [form] = Form.useForm(); | ||
return ( | ||
<Form | ||
form={form} | ||
name="dependencies" | ||
autoComplete="off" | ||
style={{ maxWidth: 600 }} | ||
layout="vertical" | ||
> | ||
<Alert message=" Try modify `Password2` and then modify `Password`" type="info" showIcon /> | ||
|
||
<Form.Item label="Password" name="password" rules={[{ required: true }]}> | ||
<Input /> | ||
</Form.Item> | ||
|
||
{/* Field */} | ||
<Form.Item | ||
label="Confirm Password" | ||
name="password2" | ||
dependencies={['password']} | ||
rules={[ | ||
{ | ||
required: true, | ||
}, | ||
({ getFieldValue }) => ({ | ||
validator(_, value) { | ||
if (!value || getFieldValue('password') === value) { | ||
return Promise.resolve(); | ||
} | ||
return Promise.reject(new Error('The new password that you entered do not match!')); | ||
}, | ||
}), | ||
]} | ||
> | ||
<Input /> | ||
</Form.Item> | ||
|
||
{/* Render Props */} | ||
<Form.Item noStyle dependencies={['password2']}> | ||
{() => ( | ||
<Typography> | ||
<p> | ||
Only Update when <code>password2</code> updated: | ||
</p> | ||
<pre>{JSON.stringify(form.getFieldsValue(), null, 2)}</pre> | ||
</Typography> | ||
)} | ||
</Form.Item> | ||
</Form> | ||
); | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
## zh-CN | ||
|
||
这个例子演示了一个表单中包含多个表单控件的情况。 | ||
多个 Form.List 嵌套的使用场景。 | ||
|
||
## en-US | ||
|
||
This example demonstrates the case that a form contains multiple form controls. | ||
Multiple Form.List nested usage scenarios. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.