Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Merged
merged 10 commits into from
May 4, 2017

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Apr 15, 2017

Finishes #6265
Fixes #7299, #7596

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
Copy link
Contributor

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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

cast

@xabbuh
Copy link
Member

xabbuh commented May 4, 2017

Thank you @wouterj.

@xabbuh xabbuh merged commit 64e3984 into 2.7 May 4, 2017
xabbuh added a commit that referenced this pull request May 4, 2017
…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
@xabbuh xabbuh deleted the HeahDude-form-empty_data-option branch May 4, 2017 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants