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

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -