@@ -270,11 +270,9 @@ and fill in the listener logic::
270270 );
271271 }
272272
273- $factory = $builder->getFormFactory();
274-
275273 $builder->addEventListener(
276274 FormEvents::PRE_SET_DATA,
277- function(FormEvent $event) use($user, $factory) {
275+ function(FormEvent $event) use ($user) {
278276 $form = $event->getForm();
279277
280278 $formOptions = array(
@@ -289,7 +287,7 @@ and fill in the listener logic::
289287
290288 // create the field, this is similar the $builder->add()
291289 // field name, field type, data, options
292- $form->add($factory->createNamed( 'friend', 'entity',null, $formOptions) );
290+ $form->add('friend', 'entity', $formOptions);
293291 }
294292 );
295293 }
@@ -372,16 +370,22 @@ it with :ref:`dic-tags-form-type`.
372370 If you wish to create it from within a controller or any other service that has
373371access to the form factory, you then use::
374372
375- class FriendMessageController extends Controller
373+ use Symfony\Component\DependencyInjection\ContainerAware;
374+
375+ class FriendMessageController extends ContainerAware
376376 {
377377 public function newAction(Request $request)
378378 {
379- $form = $this->createForm ('acme_friend_message');
379+ $form = $this->get('form.factory')->create ('acme_friend_message');
380380
381381 // ...
382382 }
383383 }
384384
385+ If you extend the ``Symfony\Bundle\FrameworkBundle\Controller\Controller `` class, you can simply call::
386+
387+ $form = $this->createForm('acme_friend_message');
388+
385389You can also easily embed the form type into another form::
386390
387391 // inside some other "form type" class