-
-
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
[Form] String is the preferred value type for TextType #15404
base: 6.1
Are you sure you want to change the base?
[Form] String is the preferred value type for TextType #15404
Conversation
508816b
to
cb28cef
Compare
@xabbuh do you have any comments about this proposal? Thanks! |
]); | ||
|
||
This will still render an empty text box, but upon submission the ``John Doe`` | ||
value will be set. Use the ``data`` or ``placeholder`` options to show this |
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 wouldn't encourage the use of the inner data
option for the default value. Cause that when it's a mapped field the data
value set here will replace the bound value that comes from the underlying subject, thus it doesn't behave as a default value. There is already a warning note about it in
https://symfony.com/doc/current/reference/forms/types/text.html#data
We should use the underlying subject to the root form to set default values or a PRE_SET_DATA
event listener instead.
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.
and the placeholder
option is only for display but it also doesn't actually set an initial value for this field
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 is a copy/paste of empty_data
documentation
https://symfony.com/doc/current/reference/forms/types/text.html#empty-data
https://github.com/symfony/symfony-docs/blob/6.2/reference/forms/types/options/empty_data_description.rst.inc
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 see, maybe that's something to fix from 4.4 (in another PR).
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.
LGTM
]); | ||
|
||
This will still render an empty text box, but upon submission the ``John Doe`` | ||
value will be set. Use the ``data`` or ``placeholder`` options to show this |
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 see, maybe that's something to fix from 4.4 (in another PR).
As far as I can see, this PR requires the 2 PRs submitted to the code repository to be merged first. I've added the "waiting code merge" label to clarify it. If this is wrong, please let us know :) |
cb28cef
to
b6f42ee
Compare
Reason symfony/symfony#41514 and symfony/symfony#41516
The
text_empty_data_description.rst.inc
file is a copy ofempty_data_description.rst.inc
: