@@ -12,18 +12,10 @@ But sometimes, you don't really need to add new field types - you want
12
12
to add features on top of existing types. This is where form type
13
13
extensions come in.
14
14
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).
27
19
28
20
Form type extensions can achieve most of what custom field types can do,
29
21
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::
319
311
320
312
When displaying the form, if the underlying model has already been associated
321
313
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