Skip to content

[Twig][Form] Moved twig.form.resources to a higher level #4003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 9 additions & 19 deletions cookbook/form/form_customization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -439,29 +439,24 @@ form is rendered.

# app/config/config.yml
twig:
form:
resources:
- 'AcmeDemoBundle:Form:fields.html.twig'
form_themes:
- 'AcmeDemoBundle:Form:fields.html.twig'
# ...

.. code-block:: xml

<!-- app/config/config.xml -->
<twig:config>
<twig:form>
<resource>AcmeDemoBundle:Form:fields.html.twig</resource>
</twig:form>
<twig:form-theme>AcmeDemoBundle:Form:fields.html.twig</twig:form-theme>
<!-- ... -->
</twig:config>

.. code-block:: php

// app/config/config.php
$container->loadFromExtension('twig', array(
'form' => array(
'resources' => array(
'AcmeDemoBundle:Form:fields.html.twig',
),
'form_themes' => array(
'AcmeDemoBundle:Form:fields.html.twig',
),

// ...
Expand All @@ -477,28 +472,23 @@ resource to use such a layout:

# app/config/config.yml
twig:
form:
resources: ['form_table_layout.html.twig']
form_themes: ['form_table_layout.html.twig']
# ...

.. code-block:: xml

<!-- app/config/config.xml -->
<twig:config>
<twig:form>
<resource>form_table_layout.html.twig</resource>
</twig:form>
<twig:form-theme>form_table_layout.html.twig</twig:form-theme>
<!-- ... -->
</twig:config>

.. code-block:: php

// app/config/config.php
$container->loadFromExtension('twig', array(
'form' => array(
'resources' => array(
'form_table_layout.html.twig',
),
'form_themes' => array(
'form_table_layout.html.twig',
),

// ...
Expand Down
29 changes: 16 additions & 13 deletions reference/configuration/twig.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ TwigBundle Configuration ("twig")

twig:
exception_controller: twig.controller.exception:showAction
form:
resources:
form_themes:

# Default:
- form_div_layout.html.twig
# Default:
- form_div_layout.html.twig
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This theme is missing in the XML and in the PHP configuration example.


# Example:
- MyBundle::form.html.twig
# Example:
- MyBundle::form.html.twig
globals:

# Examples:
Expand Down Expand Up @@ -54,9 +53,8 @@ TwigBundle Configuration ("twig")
http://symfony.com/schema/dic/twig http://symfony.com/schema/dic/doctrine/twig-1.0.xsd">

<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">
<twig:form>
<twig:resource>MyBundle::form.html.twig</twig:resource>
</twig:form>
<twig:form-theme>form_div_layout.html.twig</twig:form-theme> <!-- Default -->
<twig:form-theme>MyBundle::form.html.twig</twig:form-theme>
<twig:global key="foo" id="bar" type="service" />
<twig:global key="pi">3.14</twig:global>
</twig:config>
Expand All @@ -65,10 +63,9 @@ TwigBundle Configuration ("twig")
.. code-block:: php

$container->loadFromExtension('twig', array(
'form' => array(
'resources' => array(
'MyBundle::form.html.twig',
)
'form_themes' => array(
'form_div_layout.html.twig', // Default
'MyBundle::form.html.twig',
),
'globals' => array(
'foo' => '@bar',
Expand All @@ -83,6 +80,12 @@ TwigBundle Configuration ("twig")
'strict_variables' => false,
));

.. caution::

The ``twig.form`` (``<twig:form />`` tag for xml) configuration key
has been deprecated and will be removed in 3.0. Instead, use the ``twig.form_themes``
option.

Configuration
-------------

Expand Down