mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 05:05:48 +08:00
Merge pull request #1287 from ant-design/feat-form-item
feat: support multi children for Form.Item
This commit is contained in:
commit
f5ef6e58dd
@ -28,16 +28,16 @@ export default class FormItem extends React.Component {
|
||||
return props.help;
|
||||
}
|
||||
|
||||
getOnlyChildren() {
|
||||
getOnlyControl() {
|
||||
const children = React.Children.toArray(this.props.children);
|
||||
if (children.length === 1) {
|
||||
return children[0];
|
||||
}
|
||||
return null;
|
||||
const child = children.filter((c) => {
|
||||
return c.props && '__meta' in c.props;
|
||||
})[0];
|
||||
return child !== undefined ? child : null;
|
||||
}
|
||||
|
||||
getChildProp(prop) {
|
||||
const child = this.getOnlyChildren();
|
||||
const child = this.getOnlyControl();
|
||||
return child && child.props && child.props[prop];
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
---
|
||||
|
||||
````jsx
|
||||
import { Select, Radio, Checkbox, Button, DatePicker, InputNumber, Form, Cascader } from 'antd';
|
||||
import { Select, Radio, Checkbox, Button, DatePicker, InputNumber, Form, Cascader, Icon } from 'antd';
|
||||
const Option = Select.Option;
|
||||
const RadioGroup = Radio.Group;
|
||||
const createForm = Form.create;
|
||||
@ -134,6 +134,7 @@ let Demo = React.createClass({
|
||||
<Radio value="male">男</Radio>
|
||||
<Radio value="female">女</Radio>
|
||||
</RadioGroup>
|
||||
<span><Icon type="info-circle-o" /> 暂不支持其它性别</span>
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
|
Loading…
Reference in New Issue
Block a user