Browse Source

Allow FormItem.help to be boolean

pull/859/head
afc163 9 years ago
parent
commit
8cd0a08946
  1. 3
      components/form/FormItem.jsx
  2. 28
      components/form/demo/validate.md

3
components/form/FormItem.jsx

@ -109,6 +109,7 @@ class FormItem extends React.Component {
[`${prefixCls}-item`]: true,
[`${prefixCls}-item-compact`]: this._isCompact(props.children),
[`${prefixCls}-item-with-help`]: !!props.help,
[`${props.className}`]: !!props.className,
};
return (
@ -128,7 +129,7 @@ FormItem.propTypes = {
prefixCls: React.PropTypes.string,
label: React.PropTypes.node,
labelCol: React.PropTypes.object,
help: React.PropTypes.node,
help: React.PropTypes.oneOfType([React.PropTypes.node, React.PropTypes.bool]),
validateStatus: React.PropTypes.oneOf(['', 'success', 'warning', 'error', 'validating']),
hasFeedback: React.PropTypes.bool,
wrapperCol: React.PropTypes.object,

28
components/form/demo/validate.md

@ -76,38 +76,38 @@ ReactDOM.render(
<FormItem
label="Datepicker:"
labelCol={{span: 5}}
validateStatus="error"
help>
<Col span="6">
<DatePicker />
<FormItem validateStatus="error" help="请选择正确日期">
<DatePicker />
</FormItem>
</Col>
<Col span="1">
<p className="ant-form-split">-</p>
</Col>
<Col span="6">
<DatePicker />
</Col>
<Col span="19" offset="5">
<p className="ant-form-explain">请输入正确选项</p>
<FormItem>
<DatePicker />
</FormItem>
</Col>
</FormItem>
<FormItem
label="Datepicker:"
labelCol={{span: 5}}>
labelCol={{span: 5}}
validateStatus="error"
help>
<Col span="6">
<FormItem validateStatus="error">
<DatePicker />
<p className="ant-form-explain">请输入正确选项</p>
</FormItem>
<DatePicker />
</Col>
<Col span="1">
<p className="ant-form-split">-</p>
</Col>
<Col span="6">
<FormItem>
<DatePicker />
</FormItem>
<DatePicker />
</Col>
<Col span="19" offset="5">
<p className="ant-form-explain">请选择正确日期</p>
</Col>
</FormItem>
</Form>

Loading…
Cancel
Save