Skip to content

Commit f1f5292

Browse files
committed
[CookBook] Update documentation on Generic Form Type Extensions
1 parent 0dcb9d0 commit f1f5292

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

cookbook/form/create_form_type_extension.rst

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,10 @@ But sometimes, you don't really need to add new field types - you want
1212
to add features on top of existing types. This is where form type
1313
extensions come in.
1414

15-
Form type extensions have 2 main use-cases:
16-
17-
#. You want to add a **generic feature to several types** (such as
18-
adding a "help" text to every field type);
19-
#. You want to add a **specific feature to a single type** (such
20-
as adding a "download" feature to the "file" field type).
21-
22-
In both those cases, it might be possible to achieve your goal with custom
23-
form rendering, or custom form field types. But using form type extensions
24-
can be cleaner (by limiting the amount of business logic in templates)
25-
and more flexible (you can add several type extensions to a single form
26-
type).
15+
It might be possible to achieve your goal with custom form rendering, or custom
16+
form field types. But using form type extensions can be cleaner (by limiting the
17+
amount of business logic in templates) and more flexible (you can add several
18+
type extensions to a single form type).
2719

2820
Form type extensions can achieve most of what custom field types can do,
2921
but instead of being field types of their own, **they plug into existing types**.
@@ -319,3 +311,15 @@ next to the file field. For example::
319311

320312
When displaying the form, if the underlying model has already been associated
321313
with an image, you will see it displayed next to the file input.
314+
315+
Generic Form Type Extensions
316+
----------------------------
317+
318+
Although it is not possible to have a form type extension applying to all Form
319+
Types, **most** Form Types natively available in Symfony
320+
(:doc:`/reference/forms/types`) inherit from the Form Type ``form``. Thus, a
321+
form type extension applying to ``form`` would apply to all of these.
322+
323+
A notable exception are the Buttons From Types. Plus, keep in mind that a custom
324+
Form Type which doesn't inherit neither ``form`` nor ``button`` could always be
325+
created.

0 commit comments

Comments
 (0)