@@ -264,7 +264,7 @@ directly in the template that's actually rendering the form.
264264
265265.. code-block :: html+twig
266266
267- {% extends ':: base.html.twig' %}
267+ {% extends 'base.html.twig' %}
268268
269269 {% form_theme form _self %}
270270
@@ -303,7 +303,7 @@ can now re-use the form customization across many templates:
303303
304304.. code-block :: html+twig
305305
306- {# app/Resources/views/Form /fields.html.twig #}
306+ {# app/Resources/views/form /fields.html.twig #}
307307 {% block integer_widget %}
308308 <div class="integer_widget">
309309 {% set type = type|default('number') %}
@@ -319,7 +319,7 @@ tell Symfony to use the template via the ``form_theme`` tag:
319319
320320.. code-block :: html+twig
321321
322- {% form_theme form 'AppBundle :Form: fields.html.twig' %}
322+ {% form_theme form 'form/ fields.html.twig' %}
323323
324324 {{ form_widget(form.age) }}
325325
@@ -335,13 +335,12 @@ name of all the templates as an array using the ``with`` keyword:
335335
336336.. code-block :: html+twig
337337
338- {% form_theme form with ['::common.html.twig', ':Form: fields.html.twig',
339- 'AppBundle:Form: fields.html.twig'] %}
338+ {% form_theme form with ['common.html.twig', 'form/fields.html.twig'] %}
340339
341340 {# ... #}
342341
343- The templates can be located at different bundles and they can even be stored
344- at the global `` app/Resources/views/ `` directory .
342+ The templates can also be located in different bundles, use the functional name
343+ to reference these templates, e.g. `` AcmeFormExtraBundle:form:fields.html.twig `` .
345344
346345Child Forms
347346...........
@@ -350,16 +349,16 @@ You can also apply a form theme to a specific child of your form:
350349
351350.. code-block :: html+twig
352351
353- {% form_theme form.child 'AppBundle :Form: fields.html.twig' %}
352+ {% form_theme form.child 'form/ fields.html.twig' %}
354353
355354This is useful when you want to have a custom theme for a nested form that's
356355different than the one of your main form. Just specify both your themes:
357356
358357.. code-block :: html+twig
359358
360- {% form_theme form 'AppBundle :Form: fields.html.twig' %}
359+ {% form_theme form 'form/ fields.html.twig' %}
361360
362- {% form_theme form.child 'AppBundle :Form: fields_child.html.twig' %}
361+ {% form_theme form.child 'form/ fields_child.html.twig' %}
363362
364363.. _cookbook-form-php-theming :
365364
@@ -375,9 +374,13 @@ file in order to customize the ``integer_widget`` fragment.
375374
376375.. code-block :: html+php
377376
378- <!-- app/Resources/views/Form /integer_widget.html.php -->
377+ <!-- app/Resources/views/form /integer_widget.html.php -->
379378 <div class="integer_widget">
380- <?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : "number")) ?>
379+ <?php echo $view['form']->block(
380+ $form,
381+ 'form_widget_simple',
382+ array('type' => isset($type) ? $type : "number")
383+ ) ?>
381384 </div>
382385
383386Now that you've created the customized form template, you need to tell Symfony
@@ -388,7 +391,7 @@ tell Symfony to use the theme via the ``setTheme`` helper method:
388391
389392.. code-block :: php
390393
391- <?php $view['form']->setTheme($form, array('AppBundle:Form ')); ?>
394+ <?php $view['form']->setTheme($form, array(':form ')); ?>
392395
393396 <?php $view['form']->widget($form['age']) ?>
394397
@@ -401,7 +404,14 @@ method:
401404
402405.. code-block :: php
403406
404- <?php $view['form']->setTheme($form['child'], 'AppBundle:Form/Child'); ?>
407+ <?php $view['form']->setTheme($form['child'], ':form'); ?>
408+
409+ .. note ::
410+
411+ The ``:form `` syntax is based on the functional names for templates:
412+ ``Bundle:Directory ``. As the form directory lives in the
413+ ``app/Resources/views `` directory, the ``Bundle `` part is empty, resulting
414+ in ``:form ``.
405415
406416.. _cookbook-form-twig-import-base-blocks :
407417
475485~~~~
476486
477487By using the following configuration, any customized form blocks inside the
478- ``AppBundle:Form: fields.html.twig `` template will be used globally when a
479- form is rendered.
488+ ``form/ fields.html.twig `` template will be used globally when a form is
489+ rendered.
480490
481491.. configuration-block ::
482492
@@ -485,14 +495,14 @@ form is rendered.
485495 # app/config/config.yml
486496 twig :
487497 form_themes :
488- - ' AppBundle:Form: fields.html.twig'
498+ - 'form/ fields.html.twig'
489499 # ...
490500
491501 .. code-block :: xml
492502
493503 <!-- app/config/config.xml -->
494504 <twig : config >
495- <twig : form-theme >AppBundle:Form: fields.html.twig</twig : form-theme >
505+ <twig : form-theme >form/ fields.html.twig</twig : form-theme >
496506 <!-- ... -->
497507 </twig : config >
498508
@@ -501,7 +511,7 @@ form is rendered.
501511 // app/config/config.php
502512 $container->loadFromExtension('twig', array(
503513 'form_themes' => array(
504- 'AppBundle:Form: fields.html.twig',
514+ 'form/ fields.html.twig',
505515 ),
506516
507517 // ...
@@ -677,7 +687,7 @@ customize the ``name`` field only:
677687 .. code-block :: html+php
678688
679689 <!-- Main template -->
680- <?php echo $view['form']->setTheme($form, array('AppBundle:Form ')); ?>
690+ <?php echo $view['form']->setTheme($form, array(':form ')); ?>
681691
682692 <?php echo $view['form']->widget($form['name']); ?>
683693
@@ -735,7 +745,7 @@ You can also override the markup for an entire field row using the same method:
735745 .. code-block :: html+php
736746
737747 <!-- Main template -->
738- <?php echo $view['form']->setTheme($form, array('AppBundle:Form ')); ?>
748+ <?php echo $view['form']->setTheme($form, array(':form ')); ?>
739749
740750 <?php echo $view['form']->row($form['name']); ?>
741751
0 commit comments