Skip to content

Commit 3ffc20f

Browse files
committed
bug #4103 [Cookbook][Forms] fix PHP template file name (xabbuh)
This PR was merged into the 2.3 branch. Discussion ---------- [Cookbook][Forms] fix PHP template file name | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | all | Fixed tickets | part of #4088 Commits ------- 6a14650 [Cookbook][Forms] fix PHP template file name
2 parents 234fa36 + 6a14650 commit 3ffc20f

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)