Skip to content

Commit 3cedd68

Browse files
committed
[book] [form] Ambiguous block prefixes render incorrectly
1 parent 1efdc73 commit 3cedd68

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

book/forms.rst

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ your controller::
241241
'form' => $form->createView(),
242242
));
243243
}
244-
244+
245245
.. caution::
246246

247247
Be aware that the ``createView()`` method should be called *after* ``handleRequest``
@@ -686,7 +686,7 @@ the documentation for each type.
686686
is left blank. If you don't want this behavior, either
687687
:ref:`disable HTML5 validation <book-forms-html5-validation-disable>`
688688
or set the ``required`` option on your field to ``false``::
689-
689+
690690
->add('dueDate', 'date', array(
691691
'widget' => 'single_text',
692692
'required' => false
@@ -1128,6 +1128,23 @@ the choice is ultimately up to you.
11281128
));
11291129
}
11301130

1131+
.. caution::
1132+
1133+
When the name of your form class matches any of the built-in field types,
1134+
your form might not be rendered correctly. A form
1135+
``AppBundle\\Form\\Type\\PasswordType`` to change a user password for
1136+
instance will be mistaken for the built-in ``PasswordType`` field type and
1137+
won't be rendered correctly. You can still use the class name of your choice
1138+
by overriding the ``getBlockPrefix`` method of your form class::
1139+
1140+
public function getBlockPrefix()
1141+
{
1142+
return 'app_bundle_password';
1143+
}
1144+
1145+
Read the chapter ":doc:`/cookbook/form/create_custom_field_type.html`" for
1146+
more information.
1147+
11311148
.. tip::
11321149

11331150
When mapping forms to objects, all fields are mapped. Any fields on the

0 commit comments

Comments
 (0)