diff --git a/components/form/demo/disabled.md b/components/form/demo/disabled.md index 02abcee78c..63d9a238ea 100644 --- a/components/form/demo/disabled.md +++ b/components/form/demo/disabled.md @@ -2,7 +2,7 @@ - order: 2 -1) 单独为输入框设置 `disabled` 属性; +1) 单独为输入控件设置 `disabled` 属性; 2) 为 `
` 设置 `disabled` 属性,可以禁用 `
` 中包含的所有控件。 @@ -10,42 +10,39 @@ ````jsx var Form = antd.Form; -var Input = Form.Input; -var FormItem = Form.Item; var Button = antd.Button; var Checkbox = antd.Checkbox; var Radio = antd.Radio; var RadioGroup = antd.Radio.Group; -React.render( +ReactDOM.render(
- - - + +
禁用的 fieldset - - - - + + + - - + +
- +
diff --git a/components/form/demo/form-controls.md b/components/form/demo/form-controls.md index 06ad7a6869..e785160c63 100644 --- a/components/form/demo/form-controls.md +++ b/components/form/demo/form-controls.md @@ -10,8 +10,6 @@ ````jsx var Form = antd.Form; -var Input = Form.Input; -var FormItem = Form.Item; var Select = antd.Select; var Option = Select.Option; var Checkbox = antd.Checkbox; @@ -22,23 +20,23 @@ function handleSelectChange(value) { console.log('selected ' + value); } -React.render( +ReactDOM.render( - - - + + - - - + + - @@ -48,13 +46,12 @@ React.render( - + - + wrapperClassName="col-18" > @@ -64,13 +61,12 @@ React.render( - + - + wrapperClassName="col-18" > @@ -80,20 +76,19 @@ React.render( - + - + wrapperClassName="col-18" > A B C D - + , document.getElementById('components-form-demo-form-controls')); ```` diff --git a/components/form/demo/horizontal-form.md b/components/form/demo/horizontal-form.md index 9b450e0199..fa0fbdf797 100644 --- a/components/form/demo/horizontal-form.md +++ b/components/form/demo/horizontal-form.md @@ -2,68 +2,90 @@ - order: 0 -**注意**:在我们的设计里,表单域为静态文本、`checkbox`、`radio`以及`input[type="file"]`的,其高度不同于一般的表单域,**需要将 `` 的 `isCompact` 设置为 true**。 +示例展示了如何通过使用 `Form.ValueMixin` 来获取和更新表单提交的数值。 + +**注意:** 你需要为每个输入控件声明 `name` 属性。 --- ````jsx var Form = antd.Form; -var Input = Form.Input; -var FormItem = Form.Item; var Button = antd.Button; var Checkbox = antd.Checkbox; var Radio = antd.Radio; var RadioGroup = antd.Radio.Group; var Button = antd.Button; -React.render( -
- - - - - - - - - 男的 - 女的 - - - - - - - - -
-
- -
-
-
+var Demo = React.createClass({ + mixins: [Form.ValueMixin], -, document.getElementById('components-form-demo-horizontal-form')); + getInitialState() { + return { + formData: { + userName: '大眼萌 minion', + password: undefined, + gender: 'male', + remark: undefined, + agreement: undefined, + } + }; + }, + + handleSubmit(e) { + e.preventDefault(); + console.log(this.state.formData); + }, + + render() { + var formData = this.state.formData; + return ( +
+ + + + + + + + + 男的 + 女的 + + + + + + + + +
+
+ +
+
+
+ ); + } +}); +ReactDOM.render(, document.getElementById('components-form-demo-horizontal-form')); ```` diff --git a/components/form/demo/inline-form.md b/components/form/demo/inline-form.md index 3eb0766455..a825d4eeb9 100644 --- a/components/form/demo/inline-form.md +++ b/components/form/demo/inline-form.md @@ -6,28 +6,49 @@ ````jsx var Form = antd.Form; -var Input = Form.Input; -var FormItem = Form.Item; var Checkbox = antd.Checkbox; var Button = antd.Button; -React.render( -
- - - - - - - - - - -
-, document.getElementById('components-form-demo-inline-form')); +var Demo = React.createClass({ + mixins: [Form.ValueMixin], + + getInitialState() { + return { + formData: { + userName: undefined, + password: undefined, + agreement: undefined, + } + }; + }, + + handleSubmit(e) { + e.preventDefault(); + console.log(this.state.formData); + }, + + render() { + var formData = this.state.formData; + return ( +
+ + + + + + + + + + + + ); + } +}); + +ReactDOM.render(, document.getElementById('components-form-demo-inline-form')); ```` diff --git a/components/form/demo/input-size.md b/components/form/demo/input-size.md index ad019ddf60..18e5a3f9b4 100644 --- a/components/form/demo/input-size.md +++ b/components/form/demo/input-size.md @@ -2,24 +2,33 @@ - order: 6 -我们为定义了 `.ant-input` 类的输入框提供了三种尺寸:大(-lg)、中(默认)、小(-sm),往类名添加以上后缀即可。 +我们为 `` 输入框定义了三种尺寸(大、默认、小)。 -但是在 `
` 表单里面,我们只使用**大尺寸**, 即高度为 **32px**,作为唯一的尺寸。 +css 样式引用: 定义 `.ant-input` 类的基础上加上 `.ant-input-lg .ant-input-sm` 即可。 + +`` 组件引用需要声明 `site` 属性即可,属性值为 ['small', 'default', 'large']。 + +注意: 在 `` 表单里面,我们只使用**大尺寸**, 即高度为 **32px**,作为唯一的尺寸。 --- -````html -
-
-
- -
-
- -
-
- -
+ +````jsx +var Form = antd.Form; + +ReactDOM.render( +
+ +
+ +
+
+ +
+
+ +
+
-
+, document.getElementById('components-form-demo-input-size')); ```` diff --git a/components/form/demo/inputs.md b/components/form/demo/inputs.md index 7162ca44c9..51c2542d18 100644 --- a/components/form/demo/inputs.md +++ b/components/form/demo/inputs.md @@ -6,34 +6,31 @@ ````jsx var Form = antd.Form; -var Input = Form.Input; -var FormItem = Form.Item; -var InputGroup = Input.Group; var Select = antd.Select; var Option = Select.Option; -React.render( +ReactDOM.render( - - - + + - - - + + - - - + +
-
-
+ + - - +
- +
- +
- +
- +
-
-
+ + -
- +

--

- +
- +
- +
- +
-
+
-
+ , document.getElementById('components-form-demo-inputs')); diff --git a/components/form/demo/mix.md b/components/form/demo/mix.md index 90673f3100..4c2aacae32 100644 --- a/components/form/demo/mix.md +++ b/components/form/demo/mix.md @@ -8,9 +8,6 @@ ````jsx var Form = antd.Form; -var Input = Form.Input; -var FormItem = Form.Item; -var InputGroup = Input.Group; var Select = antd.Select; var Option = Select.Option; var InputNumber = antd.InputNumber; @@ -20,112 +17,106 @@ var Menu = antd.Menu; var Dropdown = antd.Dropdown; var Slider = antd.Slider; var Icon = antd.Icon; +var Button = antd.Button; -var menu = - - .net - - - .jp - - - .org - -; +var Demo = React.createClass({ + mixins: [Form.ValueMixin], -function handleSelectChange(value) { - console.log('selected ' + value); -} + getInitialState() { + return { + formData: { + inputNumber: undefined, + static: "唧唧复唧唧木兰当户织呀", + switch: undefined, + slider: undefined, + select: undefined, + startDate: undefined, + endDate: undefined, + } + }; + }, -function onInputNumberChange(v){ - console.log('changed',v); -} + handleSubmit(e) { + e.preventDefault(); + console.log(this.state.formData); + }, -React.render( -
- - - 台机器 - + render() { + var formData = this.state.formData; + return ( + + + + 台机器 + - -

唧唧复唧唧木兰当户织呀

-

- 链接文字 -

-
+ + +

+ 链接文字 +

+
- - - + + + - - - + + + - - - + + + - -
- -
-
-

-

-
-
- -
-
+ +
+ +
+
+

-

+
+
+ +
+
+
+
+ +
+
+
+ ); + } +}); - -
- -
-
-

-

-
-
- -
-
-

请输入正确选项

-
-
- -, document.getElementById('components-form-demo-mix')); +ReactDOM.render(, document.getElementById('components-form-demo-mix')); ```` diff --git a/components/form/demo/validate.md b/components/form/demo/validate.md index 6f678b4f9b..43f423f0c4 100644 --- a/components/form/demo/validate.md +++ b/components/form/demo/validate.md @@ -2,79 +2,94 @@ - order: 4 -我们为表单控件的校验状态定义了样式,共有三种校验状态类: +我们为表单控件定义了三种校验状态,为 `` 定义 `validateStatus` 属性即可。 -`.has-success` `.has-error` `.has-warning`, 分别代表校验成功、校验失败、有警告。 +validateStatus: ['success', 'warning', 'error', 'validating']。 -将以上三种校验状态类添加到这些控件的父级元素即可。 +另外为输入框添加反馈图标,设置 `` 的 `hasFeedback` 属性值为 `true` 即可。 -另外为输入框添加反馈图标,可以更好地反馈当前的校验状态,使用 `.has-feedback` 类包裹 input 输入框即可,在这里校验状态类就要和 `.has-feedback` 类同级。 - -**注意**: 反馈图标只能使用在文本输入框 `` 元素上。 +**注意**: 反馈图标只对 `` 有效。 --- ````jsx var Form = antd.Form; -var Input = Form.Input; -var FormItem = Form.Item; -var InputGroup = Input.Group; +var Datepicker = antd.Datepicker; -React.render( +ReactDOM.render(
- - - + + - - - - + + + - - + + - - - + + - + + + + - - + + - - - + validateStatus="error"> +
+ +
+
+

-

+
+
+ +
+
+

请输入正确选项

+
+ , document.getElementById('components-form-demo-validate')); ````