Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Form] Ambiguous block prefixes render incorrectly #6744

Merged
merged 1 commit into from
Jul 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions book/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,8 @@ the documentation for each type.
is left blank. If you don't want this behavior, either
:ref:`disable HTML5 validation <book-forms-html5-validation-disable>`
or set the ``required`` option on your field to ``false``::
->add('dueDate', DateType::class, array(

->add('dueDate', 'date', array(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been Symfony\Component\Form\Extension\Core\Type\Date, shouldn't it?

'widget' => 'single_text',
'required' => false
))
Expand Down
9 changes: 9 additions & 0 deletions cookbook/form/create_custom_field_type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down