diff --git a/components/form/FormItem.jsx b/components/form/FormItem.jsx index c9647a2202..994ca35263 100644 --- a/components/form/FormItem.jsx +++ b/components/form/FormItem.jsx @@ -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]; } diff --git a/components/form/demo/validate-other.md b/components/form/demo/validate-other.md index 68c0240720..f2ab9aa71a 100644 --- a/components/form/demo/validate-other.md +++ b/components/form/demo/validate-other.md @@ -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({ + 暂不支持其它性别