@@ -39,7 +39,7 @@ Services & Configuration
39
39
40
40
If you want to modify service definitions of another bundle, you can use a compiler
41
41
pass to change the class of the service or to modify method calls. In the following
42
- example, the implementing class for the ``original-service-id `` is changed to
42
+ example, the implementing class for the ``original-service-id `` is changed to
43
43
``Acme\DemoBundle\YourService ``::
44
44
45
45
// src/Acme/DemoBundle/DependencyInjection/Compiler/OverrideServiceCompilerPass.php
@@ -72,17 +72,16 @@ associations. Learn more about this feature and its limitations in
72
72
Forms
73
73
-----
74
74
75
- In order to override a form type, it has to be registered as a service (meaning
76
- it is tagged as ``form.type ``). You can then override it as you would override any
77
- service as explained in `Services & Configuration `_. This, of course, will only
78
- work if the type is referred to by its alias rather than being instantiated,
79
- e.g.::
75
+ Form types are referred to by their fully-qualified class name::
80
76
81
- $builder->add('name', 'custom_type' );
77
+ $builder->add('name', CustomType::class );
82
78
83
- rather than::
79
+ This means that you cannot override this by creating a sub-class of ``CustomType ``
80
+ and registering it as a service and tagging it with ``form.type `` (you *could *
81
+ do this in an earlier version).
84
82
85
- $builder->add('name', new CustomType());
83
+ Instead, you should use a "form type extension" to modify the existing form type.
84
+ For more information, see :doc: `/form/create_form_type_extension `.
86
85
87
86
.. _override-validation :
88
87
@@ -93,7 +92,7 @@ Symfony loads all validation configuration files from every bundle and
93
92
combines them into one validation metadata tree. This means you are able to
94
93
add new constraints to a property, but you cannot override them.
95
94
96
- To override this, the 3rd party bundle needs to have configuration for
95
+ To overcome this, the 3rd party bundle needs to have configuration for
97
96
:doc: `validation groups </validation/groups >`. For instance, the FOSUserBundle
98
97
has this configuration. To create your own validation, add the constraints
99
98
to a new validation group:
0 commit comments