From 3cedd68a642d84efbc426cb3fe42e28a217a29b1 Mon Sep 17 00:00:00 2001 From: Jonny Schmid Date: Fri, 3 Jun 2016 00:13:04 +0100 Subject: [PATCH 1/6] [book] [form] Ambiguous block prefixes render incorrectly --- book/forms.rst | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/book/forms.rst b/book/forms.rst index 7f527d42216..e404b9e5853 100644 --- a/book/forms.rst +++ b/book/forms.rst @@ -241,7 +241,7 @@ your controller:: 'form' => $form->createView(), )); } - + .. caution:: Be aware that the ``createView()`` method should be called *after* ``handleRequest`` @@ -686,7 +686,7 @@ 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', 'date', array( 'widget' => 'single_text', 'required' => false @@ -1128,6 +1128,23 @@ the choice is ultimately up to you. )); } +.. 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 + ``AppBundle\\Form\\Type\\PasswordType`` to change a user password for + instance will be mistaken for the built-in ``PasswordType`` field type and + won't be rendered correctly. You can still use the class name of your choice + by overriding the ``getBlockPrefix`` method of your form class:: + + public function getBlockPrefix() + { + return 'app_bundle_password'; + } + + Read the chapter ":doc:`/cookbook/form/create_custom_field_type.html`" for + more information. + .. tip:: When mapping forms to objects, all fields are mapped. Any fields on the From f3453584c5d218d69a231a9d9727297412244296 Mon Sep 17 00:00:00 2001 From: Jonny Schmid Date: Fri, 3 Jun 2016 12:58:10 +0100 Subject: [PATCH 2/6] Amend wording might not -> won't --- book/forms.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/forms.rst b/book/forms.rst index e404b9e5853..cc97d3dd2d4 100644 --- a/book/forms.rst +++ b/book/forms.rst @@ -1131,7 +1131,7 @@ the choice is ultimately up to you. .. 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 + your form won't be rendered correctly. A form ``AppBundle\\Form\\Type\\PasswordType`` to change a user password for instance will be mistaken for the built-in ``PasswordType`` field type and won't be rendered correctly. You can still use the class name of your choice From acac19f6920cbd4397b1b4ae88f5195c063a498d Mon Sep 17 00:00:00 2001 From: Jonny Schmid Date: Mon, 6 Jun 2016 10:25:39 +0100 Subject: [PATCH 3/6] Ambiguity applies to any registered field type --- book/forms.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/book/forms.rst b/book/forms.rst index cc97d3dd2d4..76a87b6a49c 100644 --- a/book/forms.rst +++ b/book/forms.rst @@ -1130,12 +1130,13 @@ the choice is ultimately up to you. .. caution:: - When the name of your form class matches any of the built-in field types, - your form won't be rendered correctly. A form + When the name of your form class matches any registered field type that has + its own theme fragment, your form won't be rendered correctly. A form ``AppBundle\\Form\\Type\\PasswordType`` to change a user password for instance will be mistaken for the built-in ``PasswordType`` field type and - won't be rendered correctly. You can still use the class name of your choice - by overriding the ``getBlockPrefix`` method of your form class:: + will be rendered incorrectly using the ``password_widget`` theme fragment. + You can still use the class name of your choice by overriding the + ``getBlockPrefix`` method of your form class:: public function getBlockPrefix() { From 0cb0a4f67ac684b5185df91c9d08d12b77928221 Mon Sep 17 00:00:00 2001 From: Jonny Schmid Date: Mon, 20 Jun 2016 12:20:02 +0100 Subject: [PATCH 4/6] Fix Sphinx link --- book/forms.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/book/forms.rst b/book/forms.rst index 76a87b6a49c..fc88d703688 100644 --- a/book/forms.rst +++ b/book/forms.rst @@ -687,7 +687,7 @@ the documentation for each type. :ref:`disable HTML5 validation ` or set the ``required`` option on your field to ``false``:: - ->add('dueDate', 'date', array( + ->add('dueDate', DateType::class, array( 'widget' => 'single_text', 'required' => false )) @@ -1143,8 +1143,8 @@ the choice is ultimately up to you. return 'app_bundle_password'; } - Read the chapter ":doc:`/cookbook/form/create_custom_field_type.html`" for - more information. + Read the ":doc:`/cookbook/form/create_custom_field_type`" chapter for more + information. .. tip:: From f5f0cd42a3fd3a06eaf4c5f5adc9252ef16ef162 Mon Sep 17 00:00:00 2001 From: Jonny Schmid Date: Wed, 22 Jun 2016 13:59:00 +0100 Subject: [PATCH 5/6] Revert incorrect merge conflict resolution --- book/forms.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/forms.rst b/book/forms.rst index fc88d703688..0c2342616ff 100644 --- a/book/forms.rst +++ b/book/forms.rst @@ -687,7 +687,7 @@ the documentation for each type. :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 )) From 0ee766b0ce8a61354401f440de58b8184cbf9169 Mon Sep 17 00:00:00 2001 From: Jonny Schmid Date: Fri, 24 Jun 2016 11:20:55 +0100 Subject: [PATCH 6/6] Tweak wording --- book/forms.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/book/forms.rst b/book/forms.rst index 0c2342616ff..ba9e76ec741 100644 --- a/book/forms.rst +++ b/book/forms.rst @@ -1130,17 +1130,17 @@ the choice is ultimately up to you. .. caution:: - When the name of your form class matches any registered field type that has - its own theme fragment, your form won't be rendered correctly. A form - ``AppBundle\\Form\\Type\\PasswordType`` to change a user password for - instance will be mistaken for the built-in ``PasswordType`` field type and - will be rendered incorrectly using the ``password_widget`` theme fragment. - You can still use the class name of your choice by overriding the + When the name of your form type class matches any registered field type that + has its own theme fragment, your form won't be rendered correctly. A form + type named ``AppBundle\\Form\\Type\\PasswordType`` to change a user password + for instance will be mistaken for the built-in ``PasswordType`` field type + and will be rendered incorrectly using the ``password_widget`` theme + fragment. You can still use the class name of your choice by overriding the ``getBlockPrefix`` method of your form class:: public function getBlockPrefix() { - return 'app_bundle_password'; + return 'app_password'; } Read the ":doc:`/cookbook/form/create_custom_field_type`" chapter for more