-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Renamed the option "empty_value" to "placeholder" #6475
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
i think "placeholder" may confuse some developers. I think "empty_value" reflect it meaning better, than "placeholder". There is "placeholder" in html forms already http://www.w3schools.com/html5/att_input_placeholder.asp |
@wiistriker this is exactly what this PR is about... |
@Tobion if i understand it right, this PR affect and choice field. https://github.com/symfony/symfony/pull/6475/files#L1L108 i think for |
@@ -165,21 +165,26 @@ public function setDefaultOptions(OptionsResolverInterface $resolver) | |||
return ''; | |||
}; | |||
|
|||
$emptyValue = function (Options $options) { | |||
$placeholderValue = function (Options $options) { | |||
return $options['required'] ? null : ''; |
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.
The value of the deprecated option should take precedence here:
return null !== $options['empty_value'] ? $options['empty_value'] : ($options['required'] ? null : '');
@wiistriker Please read #5791 for more information. |
@bschussek Are you sure about moving placeholder option from |
@norzechowicz Unfortunately I am not. Don't you feel that this is better than duplicating the placeholder logic in all the other types that need it? |
As far as I see now, checkboxes and radio buttons would be the only types that would unnecessarily have this attribute. Can you think of any other types? |
Yes, you are right about duplicating but every type that not inherits placeholder option from |
@bschussek I tried to move placeholder logic into |
id="{{ id }}" name="{{ full_name }}"{% if read_only %} readonly="readonly"{% endif %}{% if disabled %} disabled="disabled"{% endif %}{% if required %} required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}{% if pattern %} pattern="{{ pattern }}"{% endif %} | ||
{% for attrname, attrvalue in attr %}{% if attrname in ['placeholder', 'title'] %}{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}" {% else %}{{ attrname }}="{{ attrvalue }}" {% endif %}{% endfor %} | ||
id="{{ id }}" name="{{ full_name }}"{% if read_only %} readonly="readonly"{% endif %}{% if disabled %} disabled="disabled"{% endif %}{% if required %} required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}{% if pattern %} pattern="{{ pattern }}"{% endif %}{% if placeholder is defined %} placeholder="{{ placeholder|trans({}, translation_domain) }}"{% endif %} | ||
{% for attrname, attrvalue in attr %}{% if attrname in ['title'] %}{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}" {% else %}{{ attrname }}="{{ attrvalue }}" {% endif %}{% endfor %} |
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.
if 'title' == attrname
Currently I don't. I need to look into this in more detail once 2.2 is released. |
ref #9177 |
Replaced by #12003. |
Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #5791
License of the code: MIT
This PR adds
placeholder
option to types represented in html by input element and renameempty_value
option intoplaceholder
in types represented in html by select.