From b44620d89faa41847c029d63b5fce22e37b75702 Mon Sep 17 00:00:00 2001 From: Jonny Schmid Date: Fri, 3 Jun 2016 00:13:04 +0100 Subject: [PATCH] [Form] Ambiguous block prefixes render incorrectly --- book/forms.rst | 4 ++-- cookbook/form/create_custom_field_type.rst | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/book/forms.rst b/book/forms.rst index f942544d5b5..49cceafb392 100644 --- a/book/forms.rst +++ b/book/forms.rst @@ -699,8 +699,8 @@ the documentation for each type. is left blank. If you don't want this behavior, either :ref:`disable HTML5 validation ` or set the ``required`` option on your field to ``false``:: - - ->add('dueDate', DateType::class, array( + + ->add('dueDate', 'date', array( 'widget' => 'single_text', 'required' => false )) diff --git a/cookbook/form/create_custom_field_type.rst b/cookbook/form/create_custom_field_type.rst index 62ac1906751..80f0df26d34 100644 --- a/cookbook/form/create_custom_field_type.rst +++ b/cookbook/form/create_custom_field_type.rst @@ -106,6 +106,15 @@ the class name of your type. For more information, see (``GenderType`` -> ``gender``). This can be controlled by overriding ``getBlockPrefix()`` in ``GenderType``. +.. caution:: + + When the name of your form class matches any of the built-in field types, + your form might not be rendered correctly. A form type named + ``AppBundle\Form\PasswordType`` will have the same block name as the + built-in ``PasswordType`` and won't be rendered correctly. Override the + ``getBlockPrefix()`` method to return a unique block prefix (e.g. + ``app_password``) to avoid collisions. + In this case, since the parent field is ``ChoiceType``, you don't *need* to do any work as the custom field type will automatically be rendered like a ``ChoiceType``. But for the sake of this example, suppose that when your field is "expanded"