File tree 1 file changed +9
-4
lines changed
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
194
194
$vendorTwigBridgeDir.'/Resources/views/Form',
195
195
)));
196
196
$formEngine = new TwigRendererEngine(array($defaultFormTheme));
197
- $formEngine->setEnvironment($twig);
197
+ $twig->addRuntimeLoader(new \Twig_FactoryRuntimeLoader(array(
198
+ TwigRenderer::class => function () use ($formEngine, $csrfManager) {
199
+ return new TwigRenderer($formEngine, $csrfManager);
200
+ },
201
+ )));
198
202
199
203
// ... (see the previous CSRF Protection section for more information)
200
204
201
205
// add the FormExtension to Twig
202
- $twig->addExtension(
203
- new FormExtension(new TwigRenderer($formEngine, $csrfManager))
204
- );
206
+ $twig->addExtension(new FormExtension());
205
207
206
208
// create your form factory as normal
207
209
$formFactory = Forms::createFormFactoryBuilder()
208
210
// ...
209
211
->getFormFactory();
210
212
213
+ .. versionadded :: 1.30
214
+ The ``Twig_FactoryRuntimeLoader `` was introduced in Twig 1.30.
215
+
211
216
The exact details of your `Twig Configuration `_ will vary, but the goal is
212
217
always to add the :class: `Symfony\\ Bridge\\ Twig\\ Extension\\ FormExtension `
213
218
to Twig, which gives you access to the Twig functions for rendering forms.
You can’t perform that action at this time.
0 commit comments