Skip to content

Commit 0a93d6b

Browse files
committed
Merge branch '6.0' into 6.1
* 6.0: [Form] Reorder and remove duplicate methods explanation for form type Add paragraph about symfony-cli workers
2 parents 6eb0b31 + fd4b493 commit 0a93d6b

File tree

2 files changed

+36
-16
lines changed

2 files changed

+36
-16
lines changed

form/create_custom_field_type.rst

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -119,39 +119,34 @@ These are the most important methods that a form type class can define:
119119

120120
.. _form-type-methods-explanation:
121121

122-
``getParent()``
123-
When returning a (fully-qualified) class name here, Symfony will call each
124-
method of that type (i.e. ``buildForm()``, ``buildView()``, etc.) and all its
125-
type extensions, before calling the corresponding method of your custom type.
126-
This is probably a good idea if you're just changing some details of an
127-
existing type. To start from scratch, omit ``getParent()``.
128-
129122
``buildForm()``
130123
It adds and configures other types into this type. It's the same method used
131124
when :ref:`creating Symfony form classes <creating-forms-in-classes>`.
132125

133126
``buildView()``
134127
It sets any extra variables you'll need when rendering the field in a template.
135128

136-
``configureOptions()``
137-
It defines the options configurable when using the form type, which are also
138-
the options that can be used in ``buildForm()`` and ``buildView()``
139-
methods. Options are inherited from parent types and parent type
140-
extensions, but you can create any custom option you need.
141-
142129
``finishView()``
143130
This method allows to modify the "view" of any rendered widget. This is useful
144131
if your form type consists of many fields, or contains a type that produces
145132
many HTML elements (e.g. ``ChoiceType``). For any other use case, it's
146133
recommended to use ``buildView()`` instead.
147134

135+
``configureOptions()``
136+
It defines the options configurable when using the form type, which are also
137+
the options that can be used in ``buildForm()`` and ``buildView()``
138+
methods. Options are inherited from parent types and parent type
139+
extensions, but you can create any custom option you need.
140+
148141
``getParent()``
149142
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
143+
functionality), add this method to return the fully-qualified class name
151144
of that original type. Do not use PHP inheritance for this.
152145
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.
146+
``buildView()``, etc.) and type extensions of the parent before
147+
calling the ones defined in your custom type.
148+
149+
Otherwise, if your custom type is build from scratch, you can omit ``getParent()``.
155150

156151
By default, the ``AbstractType`` class returns the generic
157152
:class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\FormType`

setup/symfony_server.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,31 @@ server provides a ``run`` command to wrap them as follows:
277277
# stop the web server (and all the associated commands) when you are finished
278278
$ symfony server:stop
279279
280+
Configuring Workers
281+
-------------------
282+
283+
If you like some processes to start automatically, along with the webserver
284+
(``symfony server:start``), add a configuration file to your project:
285+
286+
.. code-block:: yaml
287+
288+
# .symfony.local.yaml
289+
workers:
290+
# built-in command that builds and watches front-end assets
291+
# yarn_encore_watch:
292+
# cmd: ['yarn', 'encore', 'dev', '--watch']
293+
yarn_encore_watch: ~
294+
295+
# built-in command that starts messenger consumer
296+
# messenger_consume_async:
297+
# cmd: ['symfony', 'console', 'messenger:consume', 'async']
298+
# watch: ['config', 'src', 'templates', 'vendor']
299+
messenger_consume_async: ~
300+
301+
# you can also add your own custom commands
302+
build_spa:
303+
cmd: ['yarn', '--cwd', './spa/', 'dev']
304+
280305
.. _symfony-server-docker:
281306

282307
Docker Integration

0 commit comments

Comments
 (0)