Skip to content

Commit 41ed361

Browse files
committed
Fix Form onSubmit
1 parent 2f2b821 commit 41ed361

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "element-react",
3-
"version": "1.1.7",
3+
"version": "1.1.8",
44
"description": "Element UI for React",
55
"private": false,
66
"main": "dist/npm/es5/index.js",

src/form/Form.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default class Form extends Component {
7373
return (
7474
<form style={this.style()} className={this.className('el-form', this.props.labelPosition && `el-form--label-${this.props.labelPosition}`, {
7575
'el-form--inline': this.props.inline
76-
})}>{this.props.children}</form>
76+
})} onSubmit={this.props.onSubmit}>{this.props.children}</form>
7777
)
7878
}
7979
}
@@ -88,7 +88,8 @@ Form.propTypes = {
8888
labelPosition: PropTypes.oneOf(['right', 'left', 'top']),
8989
labelWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
9090
labelSuffix: PropTypes.string,
91-
inline: PropTypes.bool
91+
inline: PropTypes.bool,
92+
onSubmit: PropTypes.func
9293
}
9394

9495
Form.defaultProps = {

src/form/FormItem.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,29 +156,29 @@ export default class FormItem extends Component {
156156
});
157157
}
158158

159-
labelStyle(): { width?: number } {
159+
labelStyle(): { width?: number | string } {
160160
const ret = {};
161161

162162
if (this.parent().props.labelPosition === 'top') return ret;
163163

164164
const labelWidth = this.props.labelWidth || this.parent().props.labelWidth;
165165

166166
if (labelWidth) {
167-
ret.width = Number(labelWidth);
167+
ret.width = parseInt(labelWidth);
168168
}
169169

170170
return ret;
171171
}
172172

173-
contentStyle(): { marginLeft?: number } {
173+
contentStyle(): { marginLeft?: number | string } {
174174
const ret = {};
175175

176176
if (this.parent().props.labelPosition === 'top' || this.parent().props.inline) return ret;
177177

178178
const labelWidth = this.props.labelWidth || this.parent().props.labelWidth;
179179

180180
if (labelWidth) {
181-
ret.marginLeft = Number(labelWidth);
181+
ret.marginLeft = parseInt(labelWidth);
182182
}
183183

184184
return ret;

0 commit comments

Comments
 (0)