0
私は(つまり、「パスワードが一致しない)、ここで「フィールド2フィールド1に一致しない」事をやろうとしている。パスワードリセットのgetFieldDecoratorルールですか? antdフォームで使用可能なルールにAntD枠組み
ありisn't much documentation。彼らはこれを指し。プロジェクトhere
以下は私の現在の形式である:
const ResetPasswordForm = Form.create()(React.createClass({
getInitialState() {
return {
loading: false
};
},
handleSubmit(e) {
e.preventDefault();
this.props.form.validateFields((err, values) => {
if (err) {
failure();
}
if (!err) {
let newPassword = values.newPassword;
let repeatNewPassword = values.repeatNewPassword;
handleResetPassword(newPassword, repeatNewPassword, this.props.token);
}
});
},
render() {
const { getFieldDecorator } = this.props.form;
const newPasswordRules = [
{ required: true, message: 'Please input a new password!' }
];
const repeatNewPassword = [
{ required: true, message: 'Please repeat the new password!' }
];
return (
<Form onSubmit={this.handleSubmit} className="login-form">
<FormItem>
{getFieldDecorator('newPassword', { rules: newPasswordRules })(
<Input addonBefore={<Icon type="lock" />} type="password" placeholder="New password" />
)}
</FormItem>
<FormItem>
{getFieldDecorator('repeatNewPassword', { rules: repeatNewPassword })(
<Input addonBefore={<Icon type="lock" />} type="password" placeholder="Repeat new password" />
)}
</FormItem>
<FormItem>
<Button loading={this.state.loading} type="primary" htmlType="submit" className={css(styles.loginButton)}>
Reset Password
</Button>
</FormItem>
</Form>
);
}
}));
誰もが最初のフィールドの値が2番目に一致することを確認し、ルールを作成するための正しい方向に私を指すことができれば、それは素晴らしいだろう!
何とか私が抱きしめるもの。ありがとう。 – arcom