Symfony 4 - 选项 "invalid_message" 不存在

Symfony 4 - The option "invalid_message" does not exist

我使用 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