Skip to content

Commit 63d8657

Browse files
author
Stefano Sala
committed
[Twig][Form] Moved twig.form.resources to a higher level
1 parent 2ae4f34 commit 63d8657

File tree

2 files changed

+25
-32
lines changed

2 files changed

+25
-32
lines changed

cookbook/form/form_customization.rst

+9-19
Original file line numberDiff line numberDiff line change
@@ -439,29 +439,24 @@ form is rendered.
439439
440440
# app/config/config.yml
441441
twig:
442-
form:
443-
resources:
444-
- 'AcmeDemoBundle:Form:fields.html.twig'
442+
form_themes:
443+
- 'AcmeDemoBundle:Form:fields.html.twig'
445444
# ...
446445
447446
.. code-block:: xml
448447
449448
<!-- app/config/config.xml -->
450449
<twig:config>
451-
<twig:form>
452-
<resource>AcmeDemoBundle:Form:fields.html.twig</resource>
453-
</twig:form>
450+
<twig:form-theme>AcmeDemoBundle:Form:fields.html.twig</twig:form-theme>
454451
<!-- ... -->
455452
</twig:config>
456453
457454
.. code-block:: php
458455
459456
// app/config/config.php
460457
$container->loadFromExtension('twig', array(
461-
'form' => array(
462-
'resources' => array(
463-
'AcmeDemoBundle:Form:fields.html.twig',
464-
),
458+
'form_themes' => array(
459+
'AcmeDemoBundle:Form:fields.html.twig',
465460
),
466461
467462
// ...
@@ -477,28 +472,23 @@ resource to use such a layout:
477472
478473
# app/config/config.yml
479474
twig:
480-
form:
481-
resources: ['form_table_layout.html.twig']
475+
form_themes: ['form_table_layout.html.twig']
482476
# ...
483477
484478
.. code-block:: xml
485479
486480
<!-- app/config/config.xml -->
487481
<twig:config>
488-
<twig:form>
489-
<resource>form_table_layout.html.twig</resource>
490-
</twig:form>
482+
<twig:form-theme>form_table_layout.html.twig</twig:form-theme>
491483
<!-- ... -->
492484
</twig:config>
493485
494486
.. code-block:: php
495487
496488
// app/config/config.php
497489
$container->loadFromExtension('twig', array(
498-
'form' => array(
499-
'resources' => array(
500-
'form_table_layout.html.twig',
501-
),
490+
'form_themes' => array(
491+
'form_table_layout.html.twig',
502492
),
503493
504494
// ...

reference/configuration/twig.rst

+16-13
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ TwigBundle Configuration ("twig")
1010
1111
twig:
1212
exception_controller: twig.controller.exception:showAction
13-
form:
14-
resources:
13+
form_themes:
1514
16-
# Default:
17-
- form_div_layout.html.twig
15+
# Default:
16+
- form_div_layout.html.twig
1817
19-
# Example:
20-
- MyBundle::form.html.twig
18+
# Example:
19+
- MyBundle::form.html.twig
2120
globals:
2221
2322
# Examples:
@@ -54,9 +53,8 @@ TwigBundle Configuration ("twig")
5453
http://symfony.com/schema/dic/twig http://symfony.com/schema/dic/doctrine/twig-1.0.xsd">
5554
5655
<twig:config auto-reload="%kernel.debug%" autoescape="true" base-template-class="Twig_Template" cache="%kernel.cache_dir%/twig" charset="%kernel.charset%" debug="%kernel.debug%" strict-variables="false">
57-
<twig:form>
58-
<twig:resource>MyBundle::form.html.twig</twig:resource>
59-
</twig:form>
56+
<twig:form-theme>form_div_layout.html.twig</twig:form-theme> <!-- Default -->
57+
<twig:form-theme>MyBundle::form.html.twig</twig:form-theme>
6058
<twig:global key="foo" id="bar" type="service" />
6159
<twig:global key="pi">3.14</twig:global>
6260
</twig:config>
@@ -65,10 +63,9 @@ TwigBundle Configuration ("twig")
6563
.. code-block:: php
6664
6765
$container->loadFromExtension('twig', array(
68-
'form' => array(
69-
'resources' => array(
70-
'MyBundle::form.html.twig',
71-
)
66+
'form_themes' => array(
67+
'form_div_layout.html.twig', // Default
68+
'MyBundle::form.html.twig',
7269
),
7370
'globals' => array(
7471
'foo' => '@bar',
@@ -83,6 +80,12 @@ TwigBundle Configuration ("twig")
8380
'strict_variables' => false,
8481
));
8582
83+
.. caution::
84+
85+
The ``twig.form`` (``<twig:form />`` tag for xml) configuration key
86+
has been deprecated and will be removed in 3.0. Instead, use the ``twig.form_themes``
87+
option.
88+
8689
Configuration
8790
-------------
8891

0 commit comments

Comments
 (0)