symfony - Why use FormFactory in an event subscriber event? -


Why do people use the form factor in an Event Subscriber event?

I currently have an Event Subscriber ... Public Stabilized Jobs Received Subscribed Avents () {Return Form (FormEvent :: PRE_SET_DATA = Gt; 'doSomething',); } Public Function doSomething (FormEvent $ Event) {$ form = $ event- & gt; GetForm (); ... /// Other stuff, see below /// ...}

Currently I'm using it ..

  $ Form- & gt; Add ('Field', 'Type', Options);   

But many other developers use a form factory.

  $ form-> Add ($ formFactory- & gt; createNamed ('field', 'type', blank, option);   

If both work, then what is the reason for using additional form factory object

you -> add (name, type ...) can be used only since then. Therefore, code written for older versions should use the $ formFactory to create examples of FormInterface

Comments

Popular posts from this blog

python - how we can use ajax() in views.py in django? -

matlab - Using loops to get multiple values into a cell -

python - Sequence Pattern recognition with Pybrain -