mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 20:49:53 +08:00
fix form warning
This commit is contained in:
parent
9ed2a5e803
commit
3d9ae9833e
@ -74,7 +74,7 @@ export default class Cascader extends React.Component {
|
||||
render() {
|
||||
const props = this.props;
|
||||
const [{prefixCls, children, placeholder, size, disabled,
|
||||
className, style, allowClear}, others] = splitObject(props,
|
||||
className, style, allowClear}, otherProps] = splitObject(props,
|
||||
['prefixCls', 'children','placeholder', 'size','disabled', 'className','style','allowClear']);
|
||||
|
||||
const sizeCls = classNames({
|
||||
|
@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
||||
import { FIELD_META_PROP } from './constants';
|
||||
|
||||
export default class FormItem extends React.Component {
|
||||
static defaultProps = {
|
||||
@ -52,7 +53,7 @@ export default class FormItem extends React.Component {
|
||||
getOnlyControl() {
|
||||
const children = React.Children.toArray(this.props.children);
|
||||
const child = children.filter((c) => {
|
||||
return c.props && '__meta' in c.props;
|
||||
return c.props && FIELD_META_PROP in c.props;
|
||||
})[0];
|
||||
return child !== undefined ? child : null;
|
||||
}
|
||||
@ -67,7 +68,7 @@ export default class FormItem extends React.Component {
|
||||
}
|
||||
|
||||
getMeta() {
|
||||
return this.getChildProp('__meta');
|
||||
return this.getChildProp(FIELD_META_PROP);
|
||||
}
|
||||
|
||||
renderHelp() {
|
||||
|
1
components/form/constants.tsx
Normal file
1
components/form/constants.tsx
Normal file
@ -0,0 +1 @@
|
||||
export const FIELD_META_PROP = 'data-__meta';
|
@ -34,7 +34,7 @@ let Demo = React.createClass({
|
||||
{...formItemLayout}
|
||||
label="密码"
|
||||
>
|
||||
<Input type="password" {...getFieldProps('pass')} placeholder="请输入密码" />
|
||||
<Input type="password" {...getFieldProps('pass', { initialValue: '' })} placeholder="请输入密码" />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
@ -50,13 +50,13 @@ let Demo = React.createClass({
|
||||
label="备注"
|
||||
help="随便写点什么"
|
||||
>
|
||||
<Input type="textarea" placeholder="随便写" {...getFieldProps('remark')} />
|
||||
<Input type="textarea" placeholder="随便写" {...getFieldProps('remark', { initialValue: '' })} />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label={<span>卖身华府 <Tooltip title="我为秋香"><Icon type="question-circle-o" /></Tooltip></span>}
|
||||
>
|
||||
<Checkbox {...getFieldProps('agreement')}>同意</Checkbox>
|
||||
<Checkbox {...getFieldProps('agreement', { initialValue: false, valuePropName: 'checked' })}>同意</Checkbox>
|
||||
</FormItem>
|
||||
<FormItem wrapperCol={{ span: 16, offset: 6 }} style={{ marginTop: 24 }}>
|
||||
<Button type="primary" htmlType="submit">确定</Button>
|
||||
|
@ -3,10 +3,11 @@ import FormItem from './FormItem';
|
||||
import ValueMixin from './ValueMixin';
|
||||
import createDOMForm from 'rc-form/lib/createDOMForm';
|
||||
import assign from 'object-assign';
|
||||
import { FIELD_META_PROP } from './constants';
|
||||
Form.create = (o = {}) => {
|
||||
const options = assign({}, o, {
|
||||
fieldNameProp: 'id',
|
||||
fieldMetaProp: '__meta',
|
||||
fieldMetaProp: FIELD_META_PROP,
|
||||
});
|
||||
|
||||
return createDOMForm(options);
|
||||
|
38
package.json
38
package.json
@ -42,32 +42,32 @@
|
||||
"object.omit": "^2.0.0",
|
||||
"rc-animate": "~2.3.0",
|
||||
"rc-calendar": "~5.6.2",
|
||||
"rc-cascader": "~0.9.9",
|
||||
"rc-cascader": "~0.9.10",
|
||||
"rc-checkbox": "~1.4.0",
|
||||
"rc-collapse": "~1.6.3",
|
||||
"rc-dialog": "~6.1.0",
|
||||
"rc-dialog": "~6.1.1",
|
||||
"rc-dropdown": "~1.4.8",
|
||||
"rc-form": "~0.17.1",
|
||||
"rc-input-number": "~2.5.10",
|
||||
"rc-menu": "~4.12.3",
|
||||
"rc-input-number": "~2.5.12",
|
||||
"rc-menu": "~4.12.4",
|
||||
"rc-notification": "~1.3.4",
|
||||
"rc-pagination": "~1.5.3",
|
||||
"rc-progress": "~1.0.4",
|
||||
"rc-queue-anim": "~0.11.9",
|
||||
"rc-queue-anim": "~0.11.12",
|
||||
"rc-radio": "~2.0.0",
|
||||
"rc-rate": "~1.1.1",
|
||||
"rc-select": "~6.4.0",
|
||||
"rc-slider": "~3.7.0",
|
||||
"rc-steps": "~2.1.3",
|
||||
"rc-rate": "~1.1.2",
|
||||
"rc-select": "~6.4.6",
|
||||
"rc-slider": "~3.7.3",
|
||||
"rc-steps": "~2.1.5",
|
||||
"rc-switch": "~1.4.2",
|
||||
"rc-table": "~4.3.2",
|
||||
"rc-tabs": "~5.9.1",
|
||||
"rc-time-picker": "~1.1.4",
|
||||
"rc-tooltip": "~3.3.2",
|
||||
"rc-tree": "~1.3.1",
|
||||
"rc-tree-select": "~1.7.2",
|
||||
"rc-upload": "~1.13.0",
|
||||
"rc-util": "~3.1.3",
|
||||
"rc-table": "~4.3.5",
|
||||
"rc-tabs": "~5.9.2",
|
||||
"rc-time-picker": "~1.1.5",
|
||||
"rc-tooltip": "~3.4.1",
|
||||
"rc-tree": "~1.3.5",
|
||||
"rc-tree-select": "~1.7.5",
|
||||
"rc-upload": "~1.13.3",
|
||||
"rc-util": "~3.2.1",
|
||||
"react-addons-pure-render-mixin": "~15.1.0",
|
||||
"react-slick": "~0.12.0",
|
||||
"warning": "~3.0.0"
|
||||
@ -106,8 +106,8 @@
|
||||
"pre-commit": "1.x",
|
||||
"querystring": "^0.2.0",
|
||||
"ramda": "^0.21.0",
|
||||
"rc-scroll-anim": "~0.2.8",
|
||||
"rc-tween-one": "~0.3.0",
|
||||
"rc-scroll-anim": "~0.2.11",
|
||||
"rc-tween-one": "~0.6.20",
|
||||
"react": "^15.0.0",
|
||||
"react-addons-test-utils": "^15.0.0",
|
||||
"react-copy-to-clipboard": "^4.0.1",
|
||||
|
Loading…
Reference in New Issue
Block a user