From ceedccae7c74573f20d00363c3f7b99d6e07b913 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Mon, 3 Jan 2022 15:08:35 +0100 Subject: [PATCH] Explaining how to inject the form factory The other sentence I deleted was just repeating what was already said a few lines above. --- components/form.rst | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/components/form.rst b/components/form.rst index dfbcfdfdcb4..0f3f0fdfa9d 100644 --- a/components/form.rst +++ b/components/form.rst @@ -370,10 +370,6 @@ you need to. If your application uses global or static variables (not usually a good idea), then you can store the object on some static class or do something similar. -Regardless of how you architect your application, remember that you -should only have one form factory and that you'll need to be able to access -it throughout your application. - .. _component-form-intro-create-simple-form: Creating a simple Form @@ -382,7 +378,8 @@ Creating a simple Form .. tip:: If you're using the Symfony Framework, then the form factory is available - automatically as a service called ``form.factory``. Also, the default + automatically as a service called ``form.factory``, you can inject it as + ``Symfony\Component\Form\FormFactoryInterface``. Also, the default base controller class has a :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController::createFormBuilder` method, which is a shortcut to fetch the form factory and call ``createBuilder()`` on it.