Skip to content

Commit cc8073c

Browse files
committed
fixed wording and added finishView
1 parent e573c0a commit cc8073c

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

form/create_custom_field_type.rst

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,24 @@ There are a few methods that are particularly important:
7272
.. _form-type-methods-explanation:
7373

7474
``getParent()``
75-
This will define the type configuring the form before. It means all the
76-
other methods below will be called with this parent type and all its type
77-
extensions before calling the ones defined in your custom type.
78-
By default, all classes extend the ``AbstractType`` which defines the
79-
``FormType`` as its parent type.
75+
This return the class name of the type configuring the form before. It
76+
means all the other methods below will be called with this parent type
77+
and all its type extensions before calling the ones defined in your
78+
custom type.
79+
By default, all classes inherit the ``AbstractType::getParent()`` which
80+
defines the ``FormType`` as parent type to re-use its options and
81+
configuration.
8082

8183
``configureOptions()``
82-
This defines options for your form type that
83-
can be used in ``buildForm()`` and ``buildView()``. There are a lot of
84-
options common to all fields (see :doc:`/reference/forms/types/form`),
85-
but you can create any custom option you need.
84+
This defines options for your type that
85+
can be used in ``buildForm()`` and ``buildView()``. Options are inherited
86+
from parent types and parent types extension but you can create any custom
87+
option you need.
8688

8789
``buildForm()``
8890
Each field type has a ``buildForm()`` method, which is where
8991
you configure and build any field(s) depending on options defined in
90-
``configureOptions()`` as well as those defined in parent types and
91-
their type extensions.
92+
``configureOptions()``.
9293
Notice that this is the same method you use to set up *your* forms, and it
9394
works the same here.
9495

@@ -99,13 +100,14 @@ There are a few methods that are particularly important:
99100
set) the ``multiple`` attribute on the ``select`` field. See
100101
`Creating a Template for the Field`_ for more details.
101102

103+
``finishView``
104+
Same as ``buildView`` but to configure the nested field views.
105+
This method as no use with types that build compound forms.
106+
102107
.. tip::
103108

104-
If you're creating a field that consists of many fields, then be sure
105-
to set your "parent" type as ``FormType::class`` or something that extends
106-
it.
107-
Also, if you need to modify the "view" of any of your child types from
108-
your parent type, use the ``finishView()`` method.
109+
If you're creating a field that consists nested fields, then be sure
110+
to set the parent type as ``FormType::class`` or one of its child.
109111

110112
The goal of this field was to extend the choice type to enable selection of the
111113
shipping type. This is achieved by fixing the ``choices`` to a list of available

0 commit comments

Comments
 (0)