Pass custom parameters to custom ValidationConstraint in Symfony2

后端 未结 5 1045
梦谈多话
梦谈多话 2021-02-04 02:25

I\'m creating a form in Symfony2. The form only contains one book field which allows the user to choose between a list of Books entities. I need to c

5条回答
  •  北恋
    北恋 (楼主)
    2021-02-04 03:06

    Thank you @JasonRoman, Your solution worked perfectly for me in Symfony 3.4.

    I had an error in my Validator when I used :

     $author = $this->constraint->getAuthor();
    

    But it worked when I used this instead :

     $author = $constraint->getAuthor();
    

提交回复
热议问题