-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Form] Make difference between data and empty_data options more visisble #7802
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
Conversation
value will be set. Use the ``data`` or ``placeholder`` options to show this | ||
initial value in the rendered form. | ||
|
||
If a form is compound, you can set ``empty_data`` as an array with field names |
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.
when data_class
is null, otherwise it has to match the class set for this option.
this default value. | ||
The ``data`` option *always* overrides the value taken from the domain data | ||
(object) when rendering. This means the object value is also overriden when | ||
the form edits an already persisted object, causing it to loose it's |
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.
[...] to lose its persisted [...]
|
||
:doc:`Form data transformers </form/data_transformers>` will still be | ||
applied to the ``empty_data`` value. This means that an empty string will | ||
be casted to ``null``. Use a custom data transformer if you explicitly want |
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.
cast
Thank you @wouterj. |
…s more visisble (HeahDude, wouterj, javiereguiluz) This PR was merged into the 2.7 branch. Discussion ---------- [Form] Make difference between data and empty_data options more visisble Finishes #6265 Fixes #7299, #7596 Commits ------- 64e3984 Fixed a minor typo df9b878 Fixed a minor typo f375489 Better explain empty_data values d552ea3 Readd mixed type for empty_data, it can be string, array or object 188f0ab Tried to write the important points more explicitly 5f3813d Updated the example add added a caution 4fd2d96 Addressed @stof's comment 242941a improved accuracy 67c93b6 fix typo 87b3542 explicit differences between 'data' & 'empty_data' in FormType
Finishes #6265
Fixes #7299, #7596