ant-design/components/form/Form.jsx

46 lines
1012 B
React
Raw Normal View History

2015-10-09 13:53:04 +08:00
import React from 'react';
import classNames from 'classnames';
2015-10-09 13:53:04 +08:00
export default class Form extends React.Component {
static defaultProps = {
prefixCls: 'ant-form',
onSubmit(e) {
e.preventDefault();
},
}
static propTypes = {
prefixCls: React.PropTypes.string,
horizontal: React.PropTypes.bool,
inline: React.PropTypes.bool,
form: React.PropTypes.object,
children: React.PropTypes.any,
onSubmit: React.PropTypes.func,
}
static childContextTypes = {
form: React.PropTypes.object,
}
2016-01-21 16:23:35 +08:00
getChildContext() {
return {
form: this.props.form,
};
}
2015-10-09 13:53:04 +08:00
render() {
const { prefixCls, className, style } = this.props;
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-10-09 13:53:04 +08:00
return (
<form {...this.props} className={formClassName} style={style}>
2015-10-09 13:53:04 +08:00
{this.props.children}
</form>
);
}
}