Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions cookbook/form/dynamic_form_modification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -408,13 +408,15 @@ it with :ref:`dic-tags-form-type`.
.. code-block:: php

// app/config/config.php
$definition = new Definition('AppBundle\Form\Type\FriendMessageFormType');
$definition->addTag('form.type', array('alias' => 'app_friend_message'));
$container->setDefinition(
'app.form.friend_message',
$definition,
array('security.context')
use Symfony\Component\DependencyInjection\Reference;

$definition = new Definition(
'AppBundle\Form\Type\FriendMessageFormType',
array(new Reference('security.context'))
);
$definition->addTag('form.type', array('alias' => 'app_friend_message'));

$container->setDefinition('app.form.friend_message', $definition);

If you wish to create it from within a service that has access to the form factory,
you then use::
Expand Down