Pass custom parameters to custom ValidationConstraint in Symfony2

后端 未结 5 1090
梦谈多话
梦谈多话 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:14

    Start by adding a setAuthor method to your constraint and then tweaking the validate method. The trick then is to determine the best place to call it.

    It's not clear exactly how you are binding the validator to your book. Are you using validation.yml or doing something inside of the form?

提交回复
热议问题