Skip to content

Commit 0dcb9d0

Browse files
committed
Cleans up the DIC Tags reference for Form Type Extensions
Avoid duplicating documentation by redirecting to the cookbook entry (as many other entries do).
1 parent fa90e24 commit 0dcb9d0

File tree

1 file changed

+2
-62
lines changed

1 file changed

+2
-62
lines changed

reference/dic_tags.rst

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -296,68 +296,8 @@ form.type_extension
296296
297297
**Purpose**: Create a custom "form extension"
298298
299-
Form type extensions are a way for you took "hook into" the creation of any
300-
field in your form. For example, the addition of the CSRF token is done via
301-
a form type extension (:class:`Symfony\\Component\\Form\\Extension\\Csrf\\Type\\FormTypeCsrfExtension`).
302-
303-
A form type extension can modify any part of any field in your form. To create
304-
a form type extension, first create a class that implements the
305-
:class:`Symfony\\Component\\Form\\FormTypeExtensionInterface` interface.
306-
For simplicity, you'll often extend an
307-
:class:`Symfony\\Component\\Form\\AbstractTypeExtension` class instead of
308-
the interface directly::
309-
310-
// src/Acme/MainBundle/Form/Type/MyFormTypeExtension.php
311-
namespace Acme\MainBundle\Form\Type;
312-
313-
use Symfony\Component\Form\AbstractTypeExtension;
314-
315-
class MyFormTypeExtension extends AbstractTypeExtension
316-
{
317-
// ... fill in whatever methods you want to override
318-
// like buildForm(), buildView(), finishView(), setDefaultOptions()
319-
}
320-
321-
In order for Symfony to know about your form extension and use it, give it
322-
the ``form.type_extension`` tag:
323-
324-
.. configuration-block::
325-
326-
.. code-block:: yaml
327-
328-
services:
329-
main.form.type.my_form_type_extension:
330-
class: Acme\MainBundle\Form\Type\MyFormTypeExtension
331-
tags:
332-
- { name: form.type_extension, alias: field }
333-
334-
.. code-block:: xml
335-
336-
<?xml version="1.0" encoding="UTF-8" ?>
337-
<container xmlns="http://symfony.com/schema/dic/services"
338-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
339-
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
340-
341-
<services>
342-
<service
343-
id="main.form.type.my_form_type_extension"
344-
class="Acme\MainBundle\Form\Type\MyFormTypeExtension">
345-
346-
<tag name="form.type_extension" alias="field" />
347-
</service>
348-
</services>
349-
</container>
350-
351-
.. code-block:: php
352-
353-
$container
354-
->register('main.form.type.my_form_type_extension', 'Acme\MainBundle\Form\Type\MyFormTypeExtension')
355-
->addTag('form.type_extension', array('alias' => 'field'))
356-
;
357-
358-
The ``alias`` key of the tag is the type of field that this extension should
359-
be applied to. For example, to apply the extension to any form/field, use the
360-
"form" value.
299+
For details on creating Form type extensions, read the cookbook article:
300+
:doc:`/cookbook/form/create_form_type_extension`
361301
362302
.. _reference-dic-type_guesser:
363303

0 commit comments

Comments
 (0)