重置密码时 Invalid_message 未以正确格式显示
我的重置表单看起来像是
$builder
->add('plainPassword', RepeatedType::class, [
'type' => PasswordType::class,
'first_options' => [
'attr' => ['autocomplete' => 'new-password'],
'constraints' => [
new NotBlank([
'message' => 'Please enter a password',
]),
new Length([
'min' => 6,
'minMessage' => 'Your password should be at least {{ limit }} characters',
// max length allowed by Symfony for security reasons
'max' => 4096,
]),
],
'label' => 'New password',
],
'second_options' => [
'attr' => ['autocomplete' => 'new-password'],
'label' => 'Repeat Password',
],
'invalid_message' => 'The password fields must match.',
// Instead of being set onto the object directly,
// this is read and encoded in the controller
'mapped' => false,
])
;
在执行测试,以检查我是否输入了错误的密码,而不是网页的外观。问题是新密码输入框后显示无效消息(如下所示)。我希望“密码字段必须匹配”位于新密码之上
Reset your password
New password
The password fields must match.
|INPUTBOX|
Repeat Password|INPUTBOX|
My reset form looks like
$builder
->add('plainPassword', RepeatedType::class, [
'type' => PasswordType::class,
'first_options' => [
'attr' => ['autocomplete' => 'new-password'],
'constraints' => [
new NotBlank([
'message' => 'Please enter a password',
]),
new Length([
'min' => 6,
'minMessage' => 'Your password should be at least {{ limit }} characters',
// max length allowed by Symfony for security reasons
'max' => 4096,
]),
],
'label' => 'New password',
],
'second_options' => [
'attr' => ['autocomplete' => 'new-password'],
'label' => 'Repeat Password',
],
'invalid_message' => 'The password fields must match.',
// Instead of being set onto the object directly,
// this is read and encoded in the controller
'mapped' => false,
])
;
I was performing testing to check if I enter wrong password than how the web page looks like. The problem is the invalid message shows after new password input box (like below). I want the "The password fields must match" to be on top of New Password
Reset your password
New password
The password fields must match.
|INPUTBOX|
Repeat Password|INPUTBOX|
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在你的树枝页面中,你应该显示这样的表单:
in your twig page you should display the form like that: