[LC] createForm() in ComponentWithFormTrait #2479
-
Hello, Just a thought as I browsed the doc at the form part, and it seems that currently to use forms you have to extend AbstractController and use ComponentWithFormTrait. I checked my usecases, and it seems that the only reason why I need AbstractController extended, is for its createForm() method. So I wonder if it's possible to "inject" FormFactoryInterface into ComponentWithFormTrait to make the same method, and therefore diminish the need of AbstractController inheritance? I looked at how LC traits are built, and I didn't understand how services are served into properties, but they definitely are. So one may need AbstractController for other use cases, but for this one, that's a nice saving! Sorry if it was naive, happy new year everyone and long live UX! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hi, For sure you can inject form factory through constructor and use it. I never extend AbstractController :) |
Beta Was this translation helpful? Give feedback.
As I said, there is no need for AbstractController, implement the instantiateForm method using your injected formFactory and that's all