-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Block prefix ambiguity #6636
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
Closed
Closed
Block prefix ambiguity #6636
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
888c61c
Remove old File Upload article + improve the new one
wouterj 758e083
feature #6040 Remove old File Upload article + improve the new one (W…
xabbuh fa92eac
Merge branch '2.3' into 2.7
xabbuh b2699f7
[book] [form] Ambiguous block prefixes render incorrectly
jonny-no1 1f50184
Amend wording might not -> won't
jonny-no1 47f358e
Ambiguity applies to any registered field type
jonny-no1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -241,7 +241,7 @@ your controller:: | |
'form' => $form->createView(), | ||
)); | ||
} | ||
|
||
.. caution:: | ||
|
||
Be aware that the ``createView()`` method should be called *after* ``handleRequest`` | ||
|
@@ -680,7 +680,7 @@ 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', 'date', array( | ||
'widget' => 'single_text', | ||
'required' => false | ||
|
@@ -1122,6 +1122,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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
``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 | ||
|
@@ -1947,18 +1964,17 @@ HTML form so that the user can modify that data. The second goal of a form is to | |
take the data submitted by the user and to re-apply it to the object. | ||
|
||
There's still much more to learn about the powerful world of forms, such as | ||
how to handle | ||
:doc:`file uploads with Doctrine </cookbook/doctrine/file_uploads>` or how | ||
to create a form where a dynamic number of sub-forms can be added (e.g. a | ||
todo list where you can keep adding more fields via JavaScript before submitting). | ||
how to handle :doc:`file uploads </cookbook/controller/upload_file>` or how to | ||
create a form where a dynamic number of sub-forms can be added (e.g. a todo | ||
list where you can keep adding more fields via JavaScript before submitting). | ||
See the cookbook for these topics. Also, be sure to lean on the | ||
:doc:`field type reference documentation </reference/forms/types>`, which | ||
includes examples of how to use each field type and its options. | ||
|
||
Learn more from the Cookbook | ||
---------------------------- | ||
|
||
* :doc:`/cookbook/doctrine/file_uploads` | ||
* :doc:`/cookbook/controller/upload_file` | ||
* :doc:`File Field Reference </reference/forms/types/file>` | ||
* :doc:`Creating Custom Field Types </cookbook/form/create_custom_field_type>` | ||
* :doc:`/cookbook/form/form_customization` | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not only apply to the built-in types, but is also true for any other form type that is coming from third-party bundles/libraries.