为什么人们在事件订阅者事件中使用FormFactory?
我目前有一个像这样的活动订阅者......
public static function getSubscribedEvents()
{
return array(
FormEvent::PRE_SET_DATA => 'doSomething',
);
}
public function doSomething(FormEvent $event)
{
$form = $event->getForm();
... /// other stuff, see below /// ...
}
目前我正在使用..
$form->add('field', 'type', options);
但是很多其他开发人员都使用表单工厂..
$form->add($formFactory->createNamed('field', 'type', null, options);
两者似乎都有用,所以使用额外表单工厂对象的原因是什么?