2015-10-09 13:53:04 +08:00
|
|
|
import React from 'react';
|
2015-11-24 20:03:57 +08:00
|
|
|
import classNames from 'classnames';
|
2015-10-09 13:53:04 +08:00
|
|
|
|
|
|
|
class Form extends React.Component {
|
2016-01-21 16:23:35 +08:00
|
|
|
getChildContext() {
|
|
|
|
return {
|
|
|
|
form: this.props.form,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-10-09 13:53:04 +08:00
|
|
|
render() {
|
2016-03-30 11:01:09 +08:00
|
|
|
const { prefixCls, className, style } = this.props;
|
2015-12-25 14:30:28 +08:00
|
|
|
const formClassName = classNames({
|
2015-10-09 13:53:04 +08:00
|
|
|
[`${prefixCls}-horizontal`]: this.props.horizontal,
|
|
|
|
[`${prefixCls}-inline`]: this.props.inline,
|
2016-03-30 10:58:37 +08:00
|
|
|
[className]: !!className,
|
2015-12-25 14:30:28 +08:00
|
|
|
});
|
2015-10-09 13:53:04 +08:00
|
|
|
|
|
|
|
return (
|
2016-03-30 11:01:09 +08:00
|
|
|
<form {...this.props} className={formClassName} style={style}>
|
2015-10-09 13:53:04 +08:00
|
|
|
{this.props.children}
|
|
|
|
</form>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Form.propTypes = {
|
|
|
|
prefixCls: React.PropTypes.string,
|
|
|
|
horizontal: React.PropTypes.bool,
|
|
|
|
inline: React.PropTypes.bool,
|
2016-01-21 16:23:35 +08:00
|
|
|
form: React.PropTypes.object,
|
2015-10-09 13:53:04 +08:00
|
|
|
children: React.PropTypes.any,
|
|
|
|
onSubmit: React.PropTypes.func,
|
|
|
|
};
|
|
|
|
|
|
|
|
Form.defaultProps = {
|
|
|
|
prefixCls: 'ant-form',
|
2016-03-11 16:22:38 +08:00
|
|
|
onSubmit(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
},
|
2015-10-09 13:53:04 +08:00
|
|
|
};
|
|
|
|
|
2016-01-21 16:23:35 +08:00
|
|
|
Form.childContextTypes = {
|
|
|
|
form: React.PropTypes.object,
|
|
|
|
};
|
|
|
|
|
2015-10-09 13:53:04 +08:00
|
|
|
module.exports = Form;
|