File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -370,16 +370,22 @@ it with :ref:`dic-tags-form-type`.
370
370
If you wish to create it from within a controller or any other service that has
371
371
access to the form factory, you then use::
372
372
373
- class FriendMessageController extends Controller
373
+ use Symfony\Component\DependencyInjection\ContainerAware;
374
+
375
+ class FriendMessageController extends ContainerAware
374
376
{
375
377
public function newAction(Request $request)
376
378
{
377
- $form = $this->createForm ('acme_friend_message');
379
+ $form = $this->get('form.factory')->create ('acme_friend_message');
378
380
379
381
// ...
380
382
}
381
383
}
382
384
385
+ If you extend the ``Symfony\Bundle\FrameworkBundle\Controller\Controller `` class, you can simply call::
386
+
387
+ $form = $this->createForm('acme_friend_message');
388
+
383
389
You can also easily embed the form type into another form::
384
390
385
391
// inside some other "form type" class
You can’t perform that action at this time.
0 commit comments