8000 [Cookbook][Forms] fix PHP template file name · symfony/symfony-docs@6a14650 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6a14650

Browse files
committed
[Cookbook][Forms] fix PHP template file name
1 parent 234fa36 commit 6a14650

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

cookbook/form/create_custom_field_type.rst

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ link for details), create a ``gender_widget`` block to handle this:
129129

130130
.. code-block:: html+php
131131

132-
<!-- src/Acme/DemoBundle/Resources/views/Form/gender_widget.html.twig -->
132+
<!-- src/Acme/DemoBundle/Resources/views/Form/gender_widget.html.php -->
133133
<?php if ($expanded) : ?>
134134
<ul <?php $view['form']->block($form, 'widget_container_attributes') ?>>
135135
<?php foreach ($form as $child) : ?>
@@ -151,6 +151,8 @@ link for details), create a ``gender_widget`` block to handle this:
151151
Further, the main config file should point to the custom form template
152152
so that it's used when rendering all forms.
153153

154+
When using Twig this is:
155+
154156
.. configuration-block::
155157

156158
.. code-block:: yaml
@@ -181,6 +183,51 @@ link for details), create a ``gender_widget`` block to handle this:
181183
),
182184
));
183185
186+
For the PHP templating engine, your configuration should look like this:
187+
188+
.. configuration-block::
189+
190+
.. code-block:: yaml
191+
192+
# app/config/config.yml
193+
framework:
194+
templating:
195+
form:
196+
resources:
197+
- 'AcmeDemoBundle:Form'
198+
199+
.. code-block:: xml
200+
201+
<!-- app/config/config.xml -->
202+
<?xml version="1.0" encoding="UTF-8" ?>
203+
<container xmlns="http://symfony.com/schema/dic/services"
204+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
205+
xmlns:framework="http://symfony.com/schema/dic/symfony"
206+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
207+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
208+
209+
<framework:config>
210+
<framework:templating>
211+
<framework:form>
212+
<framework:resource>AcmeDemoBundle:Form</twig:resource>
213+
</framework:form>
214+
</framework:templating>
215+
</framework:config>
216+
</container>
217+
218+
.. code-block:: php
219+
220+
// app/config/config.php
221+
$container->loadFromExtension('framework', array(
222+
'templating' => array(
223+
'form' => array(
224+
'resources' => array(
225+
'AcmeDemoBundle:Form',
226+
),
227+
),
228+
),
229+
));
230+
184231
Using the Field Type
185232
--------------------
186233

0 commit comments

Comments
 (0)
0