Skip to content

Commit f321253

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 68db46c commit f321253

File tree

1 file changed

+2
-66
lines changed

1 file changed

+2
-66
lines changed

reference/dic_tags.rst

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

366302
.. _reference-dic-type_guesser:
367303

0 commit comments

Comments
 (0)