Skip to content

Commit 87efc95

Browse files
committed
A more positivily worded version
1 parent a309be8 commit 87efc95

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

cookbook/form/create_form_type_extension.rst

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ 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 **specific feature to a single type** (such
18+
as adding a "download" feature to the "file" field type);
19+
#. You want to add a **generic feature to several types** (such as
20+
adding a "help" text to every "text" or "choice"-like type).
21+
1522
It might be possible to achieve your goal with custom form rendering, or custom
1623
form field types. But using form type extensions can be cleaner (by limiting the
1724
amount of business logic in templates) and more flexible (you can add several
@@ -315,11 +322,14 @@ with an image, you will see it displayed next to the file input.
315322
Generic Form Type Extensions
316323
----------------------------
317324

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`` form type. Thus, a
321-
form type extension applying to ``form`` would apply to all of these.
322-
323-
A notable exception are the ``button`` 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.
325+
You can modify several form types at once by specifying their common parent
326+
(:doc:`/reference/forms/types`). For example, several form types natively
327+
available in Symfony inherit from the ``text`` form type (such as ``email``,
328+
``search``, ``url``, etc.). A form type extension applying to ``text`` would
329+
apply to all of these form types.
330+
331+
In the same way, since **most** form types natively available in Symfony inherit
332+
from the ``form`` form type, a form type extension applying to ``form`` would
333+
apply to all of these. A notable exception are the ``button`` form types. Plus,
334+
keep in mind that a custom form type which inherit neither ``form`` nor
335+
``button`` could always be created.

0 commit comments

Comments
 (0)