2016-03-31 09:40:55 +08:00
|
|
|
|
---
|
|
|
|
|
order: 3
|
2016-09-01 11:48:38 +08:00
|
|
|
|
title:
|
2016-07-31 09:53:51 +08:00
|
|
|
|
zh-CN: 表单控件
|
|
|
|
|
en-US: Form controls
|
2016-03-31 09:40:55 +08:00
|
|
|
|
---
|
2015-06-15 20:24:01 +08:00
|
|
|
|
|
2016-07-31 09:53:51 +08:00
|
|
|
|
## zh-CN
|
|
|
|
|
|
2015-06-15 20:24:01 +08:00
|
|
|
|
展示所有支持的表单控件。
|
|
|
|
|
|
2016-07-31 10:01:58 +08:00
|
|
|
|
**注**: 输入框:只有正确设置了 type 属性的输入控件才能被赋予正确的样式。
|
2015-06-15 20:24:01 +08:00
|
|
|
|
|
2016-07-31 09:53:51 +08:00
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
|
|
A list off all the controls that can be used with form.
|
|
|
|
|
|
2016-09-01 11:48:38 +08:00
|
|
|
|
**Note**: Input control: Only if set correct type for it, then it will be set correct style.
|
2016-07-31 09:53:51 +08:00
|
|
|
|
|
2015-07-20 20:35:48 +08:00
|
|
|
|
````jsx
|
2016-01-27 16:44:50 +08:00
|
|
|
|
import { Form, Input, Select, Checkbox, Radio } from 'antd';
|
2015-10-29 08:41:51 +08:00
|
|
|
|
const FormItem = Form.Item;
|
|
|
|
|
const Option = Select.Option;
|
|
|
|
|
const RadioGroup = Radio.Group;
|
2015-07-20 20:35:48 +08:00
|
|
|
|
|
|
|
|
|
function handleSelectChange(value) {
|
2016-02-17 18:04:42 +08:00
|
|
|
|
console.log(`selected ${value}`);
|
2015-07-20 20:35:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-25 11:35:03 +08:00
|
|
|
|
ReactDOM.render(
|
2015-10-29 08:41:51 +08:00
|
|
|
|
<Form horizontal>
|
|
|
|
|
<FormItem
|
|
|
|
|
id="control-input"
|
2016-07-31 09:53:51 +08:00
|
|
|
|
label="input control"
|
2016-01-27 16:44:50 +08:00
|
|
|
|
labelCol={{ span: 6 }}
|
2016-06-06 13:54:10 +08:00
|
|
|
|
wrapperCol={{ span: 14 }}
|
|
|
|
|
>
|
2015-10-29 08:41:51 +08:00
|
|
|
|
<Input id="control-input" placeholder="Please enter..." />
|
|
|
|
|
</FormItem>
|
2015-10-09 15:44:10 +08:00
|
|
|
|
|
2015-10-29 08:41:51 +08:00
|
|
|
|
<FormItem
|
|
|
|
|
id="control-textarea"
|
2016-07-31 09:53:51 +08:00
|
|
|
|
label="text area"
|
2016-01-27 16:44:50 +08:00
|
|
|
|
labelCol={{ span: 6 }}
|
2016-06-06 13:54:10 +08:00
|
|
|
|
wrapperCol={{ span: 14 }}
|
|
|
|
|
>
|
2015-12-16 20:13:18 +08:00
|
|
|
|
<Input type="textarea" id="control-textarea" rows="3" />
|
2015-10-29 08:41:51 +08:00
|
|
|
|
</FormItem>
|
2015-10-09 15:44:10 +08:00
|
|
|
|
|
2015-10-29 08:41:51 +08:00
|
|
|
|
<FormItem
|
|
|
|
|
id="select"
|
2016-07-31 09:53:51 +08:00
|
|
|
|
label="Select box"
|
2016-01-27 16:44:50 +08:00
|
|
|
|
labelCol={{ span: 6 }}
|
2016-06-06 13:54:10 +08:00
|
|
|
|
wrapperCol={{ span: 14 }}
|
|
|
|
|
>
|
2016-01-27 16:44:50 +08:00
|
|
|
|
<Select id="select" size="large" defaultValue="lucy" style={{ width: 200 }} onChange={handleSelectChange}>
|
2015-10-29 08:41:51 +08:00
|
|
|
|
<Option value="jack">jack</Option>
|
|
|
|
|
<Option value="lucy">lucy</Option>
|
|
|
|
|
<Option value="disabled" disabled>disabled</Option>
|
2016-03-22 11:39:28 +08:00
|
|
|
|
<Option value="yiminghe">yiminghe</Option>
|
2015-10-29 08:41:51 +08:00
|
|
|
|
</Select>
|
|
|
|
|
</FormItem>
|
2015-10-09 15:44:10 +08:00
|
|
|
|
|
2015-10-29 08:41:51 +08:00
|
|
|
|
<FormItem
|
2016-07-31 09:53:51 +08:00
|
|
|
|
label="Checkbox"
|
2016-01-27 16:44:50 +08:00
|
|
|
|
labelCol={{ span: 6 }}
|
2016-06-06 13:54:10 +08:00
|
|
|
|
wrapperCol={{ span: 18 }}
|
|
|
|
|
>
|
2016-07-31 09:53:51 +08:00
|
|
|
|
<Checkbox className="ant-checkbox-vertical">item 1</Checkbox>
|
|
|
|
|
<Checkbox className="ant-checkbox-vertical">item 2</Checkbox>
|
|
|
|
|
<Checkbox className="ant-checkbox-vertical" disabled>item 3 (disabled)</Checkbox>
|
2015-10-29 08:41:51 +08:00
|
|
|
|
</FormItem>
|
2015-10-09 15:44:10 +08:00
|
|
|
|
|
2015-10-29 08:41:51 +08:00
|
|
|
|
<FormItem
|
2016-07-31 09:53:51 +08:00
|
|
|
|
label="Checkbox"
|
2016-01-27 16:44:50 +08:00
|
|
|
|
labelCol={{ span: 6 }}
|
2016-06-06 13:54:10 +08:00
|
|
|
|
wrapperCol={{ span: 18 }}
|
|
|
|
|
>
|
2016-07-31 09:53:51 +08:00
|
|
|
|
<Checkbox className="ant-checkbox-inline">item 1</Checkbox>
|
|
|
|
|
<Checkbox className="ant-checkbox-inline">item 2</Checkbox>
|
|
|
|
|
<Checkbox className="ant-checkbox-inline">item 3</Checkbox>
|
2015-10-29 08:41:51 +08:00
|
|
|
|
</FormItem>
|
2015-10-09 15:44:10 +08:00
|
|
|
|
|
2015-10-29 08:41:51 +08:00
|
|
|
|
<FormItem
|
2016-07-31 09:53:51 +08:00
|
|
|
|
label="Radio"
|
2016-01-27 16:44:50 +08:00
|
|
|
|
labelCol={{ span: 6 }}
|
2016-06-06 13:54:10 +08:00
|
|
|
|
wrapperCol={{ span: 18 }}
|
|
|
|
|
>
|
2016-03-22 11:39:28 +08:00
|
|
|
|
<RadioGroup defaultValue="b">
|
2016-02-17 18:02:33 +08:00
|
|
|
|
<Radio value="a">A</Radio>
|
|
|
|
|
<Radio value="b">B</Radio>
|
|
|
|
|
<Radio value="c">C</Radio>
|
|
|
|
|
<Radio value="d">D</Radio>
|
|
|
|
|
</RadioGroup>
|
2015-10-29 08:41:51 +08:00
|
|
|
|
</FormItem>
|
|
|
|
|
</Form>
|
2015-12-29 12:08:58 +08:00
|
|
|
|
, mountNode);
|
2015-06-15 20:24:01 +08:00
|
|
|
|
````
|