我试图在 Symfony 4.4 中显示重复密码字段的错误消息。
这是表单类文件中的相关代码:
->add('password', RepeatedType::class, array(
'required' => true,
'invalid_message' => 'Le mot de passe et sa confirmation ne sont pas identiques',
'type' => PasswordType::class,
'first_options' => array('label' => false,'error_bubbling' => true),
'second_options' => array('label' => false),
))
这是我的相关树枝/HTML代码:
<div class="col-md-4 mb-4">
<div class="form-outline">
{{ form_row(registrationForm.password.first ,{'label':false,'attr':{'placeholder':'Mot de passe', 'name':'password1', 'class':'form-control', 'id':'password1'} } ) }}
<span style="color: red">{{ form_errors(registrationForm.password|first) }}</span>
</div>
</div>
实际上,如果我更改form_errors(registrationForm.password|first)
为form_errors(registrationForm.password)
,我会得到:
但是,这不是想要的结果,因为我只需要显示一个简单的文本,我真的很想知道为什么form_errors(registrationForm.password|first)
不适合我。任何想法?