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 ... Currently I'm using it .. But many other developers use a form factory. If both work, then what is the reason for using additional form factory object you 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 /// ...}
$ Form- & gt; Add ('Field', 'Type', Options);
$ form-> Add ($ formFactory- & gt; createNamed ('field', 'type', blank, option);
-> 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
Post a Comment