Skip to content

Commit 4593baf

Browse files
Bart van den BurgBurgov
authored andcommitted
explain how to override form types
1 parent 240cf46 commit 4593baf

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

cookbook/bundles/override.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,19 @@ In progress...
4545
Forms
4646
-----
4747

48-
In progress...
48+
In order to override a form type, it has to be registered as a service (meaning
49+
it is tagged as "form.type"). You can then override it as you would override any
50+
service as explained in "Services & Configuration". This, of course, will only
51+
work if the type is referred to by its alias rather than being instantiated,
52+
e.g.:
53+
54+
.. code-block:: php
55+
$builder->add('name', 'custom_type');
56+
57+
rather than
58+
59+
.. code-block:: php
60+
$builder->add('name', new CustomType());
4961
5062
Validation metadata
5163
-------------------

0 commit comments

Comments
 (0)