diff --git a/cookbook/form/dynamic_form_modification.rst b/cookbook/form/dynamic_form_modification.rst index 7b5a5d589d2..bd65ba3d797 100644 --- a/cookbook/form/dynamic_form_modification.rst +++ b/cookbook/form/dynamic_form_modification.rst @@ -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::