Skip to content
Merged
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
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