Skip to content

Commit

Permalink
bug #4103 [Cookbook][Forms] fix PHP template file name (xabbuh)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
weaverryan committed Aug 8, 2014
2 parents 234fa36 + 6a14650 commit 3ffc20f
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion cookbook/form/create_custom_field_type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ link for details), create a ``gender_widget`` block to handle this:

.. code-block:: html+php

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

When using Twig this is:

.. configuration-block::

.. code-block:: yaml
Expand Down Expand Up @@ -181,6 +183,51 @@ link for details), create a ``gender_widget`` block to handle this:
),
));
For the PHP templating engine, your configuration should look like this:

.. configuration-block::

.. code-block:: yaml
# app/config/config.yml
framework:
templating:
form:
resources:
- 'AcmeDemoBundle:Form'
.. code-block:: xml
<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:templating>
<framework:form>
<framework:resource>AcmeDemoBundle:Form</twig:resource>
</framework:form>
</framework:templating>
</framework:config>
</container>
.. code-block:: php
// app/config/config.php
$container->loadFromExtension('framework', array(
'templating' => array(
'form' => array(
'resources' => array(
'AcmeDemoBundle:Form',
),
),
),
));
Using the Field Type
--------------------

Expand Down

0 comments on commit 3ffc20f

Please sign in to comment.