我使用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,
))
我收到了错误:
选项“invalid_message”不存在。定义的选项是....
我没有找到任何关于它的信息,我只是试图从Symfony Doc复制这个例子:https://symfony.com/doc/current/reference/forms/types/repeated.html
我需要导入一些东西吗?
invalid_message
选项属于FormTypeValidatorExtension
,当ValidatorExtension
组件可用时由Validator
加载。
您需要安装此组件以启用验证器选项:
composer require symfony/validator