Symfony 2.8/3.0 upgrade: how to deal with form types with variable parameters?

回眸只為那壹抹淺笑 提交于 2019-12-03 15:56:44

Well, after digging this topic a bit more, someone already asked the question directly in the PR concerning this change in Symfony 2.8.

And the answer is that the pattern I was doing is not possible anymore, so I see 2 solutions to my problem:

  • Create as many classes as I had services for my custom types instead of using all the time the same class, and make these classes extend an abstract one (in my example: create Gender1Type and Gender2Type classes that extend a AbstractGenderType abstract class)
  • Keep only one class, but add options to it to pass my specific parameters.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!