Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d5706e4

Browse filesBrowse files
committed
minor #11017 Added a note about PHP extension and Symfony Form types extension (javiereguiluz)
This PR was squashed before being merged into the 3.4 branch (closes #11017). Discussion ---------- Added a note about PHP extension and Symfony Form types extension Fixes #4923. Commits ------- ab7cab3 Added a note about PHP extension and Symfony Form types extension
2 parents bdd871d + ab7cab3 commit d5706e4
Copy full SHA for d5706e4

File tree

Expand file treeCollapse file tree

1 file changed

+16
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-4
lines changed

‎form/create_custom_field_type.rst

Copy file name to clipboardExpand all lines: form/create_custom_field_type.rst
+16-4Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ Defining the Field Type
1616
In order to create the custom field type, first you have to create the class
1717
representing the field. In this situation the class holding the field type
1818
will be called ``ShippingType`` and the file will be stored in the default location
19-
for form fields, which is ``<BundleName>\Form\Type``. Make sure the field extends
20-
:class:`Symfony\\Component\\Form\\AbstractType`::
19+
for form fields, which is ``<BundleName>\Form\Type``.
20+
21+
All field types must implement the :class:`Symfony\\Component\\Form\\FormTypeInterface`,
22+
but you should instead extend from :class:`Symfony\\Component\\Form\\AbstractType`,
23+
which already implements that interface and provides some utilities::
2124

2225
// src/AppBundle/Form/Type/ShippingType.php
2326
namespace AppBundle\Form\Type;
@@ -54,8 +57,17 @@ for form fields, which is ``<BundleName>\Form\Type``. Make sure the field extend
5457
Here, the return value of the ``getParent()`` function indicates that you're
5558
extending the ``ChoiceType`` field. This means that, by default, you inherit
5659
all of the logic and rendering of that field type. To see some of the logic,
57-
check out the `ChoiceType`_ class. There are three methods that are particularly
58-
important:
60+
check out the `ChoiceType`_ class.
61+
62+
.. note::
63+
64+
The PHP class extension mechanism and the Symfony form field extension
65+
mechanism are not the same. The parent type returned in ``getParent()`` is
66+
what Symfony uses to build and manage the field type. Making the PHP class
67+
extend from ``AbstractType`` is only a convenience way of implementing the
68+
required ``FormTypeInterface``.
69+
70+
There are three methods that are particularly important:
5971

6072
.. _form-type-methods-explanation:
6173

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.