handleSubmit = (e) => {
e.preventDefault();
this.props.form.validateFields((err, values) => {
if (!err) {
console.log('Received values of form: ', values);
}
});
//关键代码,不过这样会带来一个问题,校验时无法显示提示信息,解决方案看第二篇博客
this.props.form.resetFields();
};
<Form onSubmit={this.handleSubmit} layout='inline'>
<FormItem label={
channelIndexTxt ||
channelLayoutTxt ||
channelTitleTxt ||
channelDescriptionTxt ||
channelEnabledTxt
}>
{getFieldDecorator('Channel_Datum', {
rules: [{required: true, message: '必选项!'}],
})(
channelEnabledTxt ?
<Switch
checkedChildren="开"
unCheckedChildren="关"
defaultChecked
onChange={this.handleChange}
/>
:
<Input
placeholder={'pls input ' + (
channelIndexTxt ||
channelLayoutTxt ||
channelTitleTxt ||
channelDescriptionTxt
)}
/>
)}
</FormItem>
<Button type="primary" htmlType={'submit'}>修改</Button>
</Form>