Symfony validate form with mapped false form fields

后端 未结 5 1068
野的像风
野的像风 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:10

    Symfony 3.4 expression constraint based on non mapped fields :

    $resolver->setDefaults([
            'data_class' => MyClass::class,
            'constraints' => [
                new Expression([
                    'expression' => 'this["endTime"].getData() >= this["startTime"].getData()',
                    'message' => 'L\'heure de fin doit être plus grande ou égale à l\'heure de début'
                ])
            ]
        ]);
    

提交回复
热议问题