Symfony validate form with mapped false form fields

后端 未结 5 1060
野的像风
野的像风 2020-12-07 11:47

I\'ve got a form with extra fields added with the option mapped to false. But when I try to validate my form, it won\'t pass indicating \"this valu

5条回答
  •  失恋的感觉
    2020-12-07 12:16

    If you are already using a constraint then you can do this:

    $builder
        ->add('new', 'repeated', array(
                'type' => 'password',
                'required'          => true,                    
                'invalid_message' => 'crmpicco.status.password_mismatch',
                'constraints'       => array(
                    new NotBlank(),
                    new Assert\Length([
                        'min'        => 2,
                        'max'        => 50,
                        'minMessage' => 'Your first name must be at least 2  characters long',
                        'maxMessage' => 'Your first name cannot be longer than 2 characters',
                    ])
                )
            ))
        ->add('save', 'submit', array(
                'label' => 'password.form.fields.save',
            ))
        ;
    

提交回复
热议问题