【问题标题】:Symfony 4 - The option "invalid_message" does not existSymfony 4 - 选项“invalid_message”不存在
【发布时间】:2018-06-15 08:51:47
【问题描述】:

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

我需要导入一些东西吗?

【问题讨论】:

    标签: symfony symfony4


    【解决方案1】:

    invalid_message 选项属于FormTypeValidatorExtension,当Validator 组件可用时由ValidatorExtension 加载。

    您需要安装此组件以启用验证器选项:

    composer require symfony/validator
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-08
      • 1970-01-01
      相关资源
      最近更新 更多