Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony 4 - The option "invalid_message" does not exist

I use Symfony 4.1, and I try a simple usage of form builder :

    $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,
        ))

I got the error :

The option "invalid_message" does not exist. Defined options are ....

I don't find any informations on it, I just tried to copy the example from Symfony Doc : https://symfony.com/doc/current/reference/forms/types/repeated.html

Do I need to import something ?

like image 649
Vincent Decaux Avatar asked Nov 26 '25 13:11

Vincent Decaux


1 Answers

The invalid_message option belong to FormTypeValidatorExtension which is loaded by ValidatorExtension when the Validator component is available.

You need to install this component to enable the validator options:

composer require symfony/validator
like image 63
yceruto Avatar answered Nov 28 '25 02:11

yceruto



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!