Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 03c6796

Browse files
committed
Merge pull request #1458 from Burgov/override-forms
Override forms
2 parents a2e9654 + 4593baf commit 03c6796

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
@@ -99,7 +99,19 @@ In progress...
9999
Forms
100100
-----
101101

102-
In progress...
102+
In order to override a form type, it has to be registered as a service (meaning
103+
it is tagged as "form.type"). You can then override it as you would override any
104+
service as explained in "Services & Configuration". This, of course, will only
105+
work if the type is referred to by its alias rather than being instantiated,
106+
e.g.:
107+
108+
.. code-block:: php
109+
$builder->add('name', 'custom_type');
110+
111+
rather than
112+
113+
.. code-block:: php
114+
$builder->add('name', new CustomType());
103115
104116
Validation metadata
105117
-------------------

0 commit comments

Comments
 (0)