File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -194,20 +194,25 @@ to bootstrap or access Twig and add the :class:`Symfony\\Bridge\\Twig\\Extension
194194 $vendorTwigBridgeDir.'/Resources/views/Form',
195195 )));
196196 $formEngine = new TwigRendererEngine(array($defaultFormTheme));
197- $formEngine->setEnvironment($twig);
197+ $twig->addRuntimeLoader(new \Twig_FactoryRunetimeLoader(array(
198+ TwigRenderer::class => function () use ($formEngine, $csrfManager) {
199+ return new TwigRenderer($formEngine, $csrfManager);
200+ },
201+ )));
198202
199203 // ... (see the previous CSRF Protection section for more information)
200204
201205 // add the FormExtension to Twig
202- $twig->addExtension(
203- new FormExtension(new TwigRenderer($formEngine, $csrfManager))
204- );
206+ $twig->addExtension(new FormExtension());
205207
206208 // create your form factory as normal
207209 $formFactory = Forms::createFormFactoryBuilder()
208210 // ...
209211 ->getFormFactory();
210212
213+ .. versionadded :: 1.30
214+ The ``Twig_FactoryRuntimeLoader `` was introduced in Twig 1.30.
215+
211216The exact details of your `Twig Configuration `_ will vary, but the goal is
212217always to add the :class: `Symfony\\ Bridge\\ Twig\\ Extension\\ FormExtension `
213218to Twig, which gives you access to the Twig functions for rendering forms.
You can’t perform that action at this time.
0 commit comments