-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
[WIP] [2.7+] explicit differences between 'data' & 'empty_data' options in FormType #6265
Conversation
@@ -15,5 +15,5 @@ just an individual field, you can set it in the data option:: | |||
.. note:: | |||
|
|||
The default values for form fields are taken directly from the underlying | |||
data structure (e.g. an entity or an array). The ``data`` option overrides | |||
this default value. | |||
data structure matching the field name with a property of an object or a |
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.
I tried to centralize structure references in the note.
@@ -10,11 +10,12 @@ empty_data | |||
DEFAULT_PLACEHOLDER | |||
|
|||
This option determines what value the field will return when the submitted | |||
value is empty. | |||
value is empty. It does not set an initial value if none is provided when | |||
the form is rendered in a view (see ``data`` or ``placeholder`` options). |
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.
It would be nice to link the options
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.
Please can some one tell me how can I do it?
Updated. closes #6340. |
Any reviews here? There are many confusions about this. |
data structure (e.g. an entity or an array). The ``data`` option overrides | ||
this default value. | ||
data structure matching the field's name with a property of an object or a | ||
key of an array. The ``data`` option overrides this default value. |
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.
You should make it clearer than overriding the default value like this will cause issues if you are using the form to edit an object rather than to create it, as the form value will still be filled from data
even if the underlying data structure also has a value for it
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.
Thank you for this heads-up!
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.
@stof done in the sentence below
e3894be
to
133a77c
Compare
Ok there is quite some work here before it's finished. I propose to override the
with dedicated example. It would be easier with a second marker like it's currently done with What do you think? |
@HeahDude sounds like a good plan to me |
@HeahDude Do you think you may find some time to finish this one? :) |
It's hard to find some time these days, but sure I will :) In the meanwhile if someone wants to take over this PR, let it be! |
Closing in favor of #7802 |
…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
It seems to be some confusion between two options
data
and empty_data` in regard of these two old symfony issues I read yesterday (symfony/symfony#14579, symfony/symfony#16530).Probably because of their name and the fact that they both are some kind of "placeholder" in different step of the form cycle.
@jakzal advise me to open a PR here for that matter.
IMO both of their descriptions are already pretty clear.
You can see in this PR an attempt to explicit and focus on the context in which they are requested.
Any idea or suggestions are welcome.