diff --git a/components/form/FormItem.jsx b/components/form/FormItem.jsx index 98fc8b9205..c3c28167eb 100644 --- a/components/form/FormItem.jsx +++ b/components/form/FormItem.jsx @@ -98,7 +98,9 @@ class FormItem extends React.Component { isRequired() { if (this.context.form) { const meta = this.getMeta() || {}; - return (meta.validate || []).some((item) => { + const validate = (meta.validate || []); + + return validate.filter((item) => !!item.rules).some((item) => { return item.rules.some((rule) => rule.required); }); } @@ -125,6 +127,7 @@ class FormItem extends React.Component { if (typeof child.type === 'function' && !child.props.size) { return React.cloneElement(child, { size: 'large' }); } + return child; }); return [ diff --git a/components/form/demo/validate-basic.md b/components/form/demo/validate-basic.md index 16dc40e05f..23375e65d4 100644 --- a/components/form/demo/validate-basic.md +++ b/components/form/demo/validate-basic.md @@ -77,7 +77,7 @@ class BasicDemo extends React.Component { } render() { - const { getFieldProps } = this.props.form; + const { getFieldProps, getFieldError, isFieldValidating } = this.props.form; return (