Skip to content

Commit 48f0d4f

Browse files
ThomasLandauerjaviereguiluz
authored andcommitted
Expanding recommendation for finishView()...
... to include the widgets created by ChoiceType as well. Might conflict with a minor change I just did in #17066
1 parent 5857093 commit 48f0d4f

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

form/create_custom_field_type.rst

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,30 @@ These are the most important methods that a form type class can define:
133133
``buildView()``
134134
It sets any extra variables you'll need when rendering the field in a template.
135135

136-
``finishView()``
137-
When creating a form type that consists of many fields, this method allows
138-
to modify the "view" of any of those fields. For any other use case, it's
139-
recommended to use ``buildView()`` instead.
140-
141136
``configureOptions()``
142137
It defines the options configurable when using the form type, which are also
143138
the options that can be used in ``buildForm()`` and ``buildView()``
144139
methods. Options are inherited from parent types and parent type
145140
extensions, but you can create any custom option you need.
146141

142+
``finishView()``
143+
This method allows to modify the "view" of any rendered widget. This is useful
144+
if your form type consists of many fields, or contains a type that produces
145+
many HTML elements (e.g. ``ChoiceType``). For any other use case, it's
146+
recommended to use ``buildView()`` instead.
147+
148+
``getParent()``
149+
If your custom type is based on another type (i.e. they share some
150+
functionality) add this method to return the fully-qualified class name
151+
of that original type. Do not use PHP inheritance for this.
152+
Symfony will call all the form type methods (``buildForm()``,
153+
``buildView()``, etc.) of the parent type and it will call all its type
154+
extensions before calling the ones defined in your custom type.
155+
156+
By default, the ``AbstractType`` class returns the generic
157+
:class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\FormType`
158+
type, which is the root parent for all form types in the Form component.
159+
147160
Defining the Form Type
148161
~~~~~~~~~~~~~~~~~~~~~~
149162

0 commit comments

Comments
 (0)