Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wanjj_1210
ant-design
提交
9d7d70be
A
ant-design
项目概览
wanjj_1210
/
ant-design
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
ant-design
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9d7d70be
编写于
3月 15, 2018
作者:
B
Benjy Cui
提交者:
偏右
3月 15, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
docs: should not use ref for wrapped form, close: #9598 (#9685)
上级
554dec3b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
42 addition
and
39 deletion
+42
-39
.eslintrc.js
.eslintrc.js
+1
-0
components/form/demo/form-in-modal.md
components/form/demo/form-in-modal.md
+41
-39
未找到文件。
.eslintrc.js
浏览文件 @
9d7d70be
...
...
@@ -63,6 +63,7 @@ if (process.env.RUN_ENV === 'DEMO') {
'
eol-last
'
:
0
,
'
prefer-rest-params
'
:
0
,
'
react/no-multi-comp
'
:
0
,
'
react/prefer-stateless-function
'
:
0
,
'
jsx-a11y/href-no-hash
'
:
0
,
'
import/newline-after-import
'
:
0
,
});
...
...
components/form/demo/form-in-modal.md
浏览文件 @
9d7d70be
...
...
@@ -18,41 +18,43 @@ import { Button, Modal, Form, Input, Radio } from 'antd';
const
FormItem
=
Form
.
Item
;
const
CollectionCreateForm
=
Form
.
create
()(
(
props
)
=>
{
const
{
visible
,
onCancel
,
onCreate
,
form
}
=
props
;
const
{
getFieldDecorator
}
=
form
;
return
(
<
Modal
visible
=
{
visible
}
title
=
"Create a new collection"
okText
=
"Create"
onCancel
=
{
onCancel
}
onOk
=
{
onCreate
}
>
<
Form
layout
=
"vertical"
>
<
FormItem
label
=
"Title"
>
{
getFieldDecorator
(
'
title
'
,
{
rules
:
[{
required
:
true
,
message
:
'
Please input the title of collection!
'
}],
})(
<
Input
/>
)
}
</
FormItem
>
<
FormItem
label
=
"Description"
>
{
getFieldDecorator
(
'
description
'
)(<
Input
type
=
"textarea"
/>)
}
</
FormItem
>
<
FormItem
className
=
"collection-create-form_last-form-item"
>
{
getFieldDecorator
(
'
modifier
'
,
{
initialValue
:
'
public
'
,
})(
<
Radio
.
Group
>
<
Radio
value
=
"public"
>
Public
</
Radio
>
<
Radio
value
=
"private"
>
Private
</
Radio
>
</
Radio
.
Group
>
)
}
</
FormItem
>
</
Form
>
</
Modal
>
);
class
extends
React
.
Component
{
render
()
{
const
{
visible
,
onCancel
,
onCreate
,
form
}
=
this
.
props
;
const
{
getFieldDecorator
}
=
form
;
return
(
<
Modal
visible
=
{
visible
}
title
=
"Create a new collection"
okText
=
"Create"
onCancel
=
{
onCancel
}
onOk
=
{
onCreate
}
>
<
Form
layout
=
"vertical"
>
<
FormItem
label
=
"Title"
>
{
getFieldDecorator
(
'
title
'
,
{
rules
:
[{
required
:
true
,
message
:
'
Please input the title of collection!
'
}],
})(
<
Input
/>
)
}
</
FormItem
>
<
FormItem
label
=
"Description"
>
{
getFieldDecorator
(
'
description
'
)(<
Input
type
=
"textarea"
/>)
}
</
FormItem
>
<
FormItem
className
=
"collection-create-form_last-form-item"
>
{
getFieldDecorator
(
'
modifier
'
,
{
initialValue
:
'
public
'
,
})(
<
Radio
.
Group
>
<
Radio
value
=
"public"
>
Public
</
Radio
>
<
Radio
value
=
"private"
>
Private
</
Radio
>
</
Radio
.
Group
>
)
}
</
FormItem
>
</
Form
>
</
Modal
>
);
}
}
);
...
...
@@ -67,7 +69,7 @@ class CollectionsPage extends React.Component {
this
.
setState
({
visible
:
false
});
}
handleCreate
=
()
=>
{
const
form
=
this
.
form
;
const
form
=
this
.
form
Ref
.
props
.
form
;
form
.
validateFields
((
err
,
values
)
=>
{
if
(
err
)
{
return
;
...
...
@@ -78,15 +80,15 @@ class CollectionsPage extends React.Component {
this
.
setState
({
visible
:
false
});
});
}
saveFormRef
=
(
form
)
=>
{
this
.
form
=
form
;
saveFormRef
=
(
form
Ref
)
=>
{
this
.
form
Ref
=
formRef
;
}
render
()
{
return
(
<
div
>
<
Button
type
=
"primary"
onClick
=
{
this
.
showModal
}
>
New Collection
</
Button
>
<
CollectionCreateForm
r
ef
=
{
this
.
saveFormRef
}
wrappedComponentR
ef
=
{
this
.
saveFormRef
}
visible
=
{
this
.
state
.
visible
}
onCancel
=
{
this
.
handleCancel
}
onCreate
=
{
this
.
handleCreate
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录