我使用 Symfony 4.1,并尝试简单地使用表单生成器:
$builder
->add('name', TextType::class)
->add('phone', TelType::class)
->add('password', RepeatedType::class, array(
'type' => PasswordType::class,
'invalid_message' => 'Passwords don\'t match',
'options' => array('attr' => array('class' => 'password-field')),
'required' => false,
'first_options' => array('label' => 'Password'),
'second_options' => array('label' => 'Password confirmation'),
'mapped' => false,
))
我收到错误:
The option "invalid_message" does not exist. Defined options are ....
我没有找到任何相关信息,我只是尝试从 Symfony Doc 复制示例:https://symfony.com/doc/current/reference/forms/types/repeated.html
我需要导入一些东西吗?
最佳答案
invalid_message
选项属于 FormTypeValidatorExtension
,当 Validator
组件可用时,由 ValidatorExtension
加载。
您需要安装此组件才能启用验证器选项:
composer require symfony/validator
关于Symfony 4 - 选项 "invalid_message"不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50872111/