bug #15048 [Translation][Form][choice] empty_value shouldn't be translated when it has an empty value (Restless-ET)

This PR was squashed before being merged into the 2.3 branch (closes #15048).

Discussion
----------

[Translation][Form][choice] empty_value shouldn't be translated when it has an empty value

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

The same fix provided at #14997 but against ```2.3``` branch.

@webmozart As requested. :)

Commits
-------

1a5c4c6 [Translation][Form][choice] empty_value shouldn't be translated when it has an empty value
This commit is contained in:
Tobias Schultze 2015-06-27 19:53:03 +02:00
commit d270bdc952
3 changed files with 8 additions and 8 deletions

View File

@ -57,7 +57,7 @@
{%- endif -%}
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
{%- if empty_value is not none -%}
<option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ empty_value|trans({}, translation_domain) }}</option>
<option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ empty_value != '' ? empty_value|trans({}, translation_domain) }}</option>
{%- endif -%}
{%- if preferred_choices|length > 0 -%}
{% set options = preferred_choices %}

View File

@ -7,7 +7,7 @@
)) ?>
<?php if ($multiple): ?> multiple="multiple"<?php endif ?>
>
<?php if (null !== $empty_value): ?><option value=""<?php if ($required and empty($value) && '0' !== $value): ?> selected="selected"<?php endif?>><?php echo $view->escape($view['translator']->trans($empty_value, array(), $translation_domain)) ?></option><?php endif; ?>
<?php if (null !== $empty_value): ?><option value=""<?php if ($required and empty($value) && '0' !== $value): ?> selected="selected"<?php endif?>><?php echo '' != $empty_value ? $view->escape($view['translator']->trans($empty_value, array(), $translation_domain)) : '' ?></option><?php endif; ?>
<?php if (count($preferred_choices) > 0): ?>
<?php echo $view['form']->block($form, 'choice_widget_options', array('choices' => $preferred_choices)) ?>
<?php if (count($choices) > 0 && null !== $separator): ?>

View File

@ -505,7 +505,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
[@name="name"]
[not(@required)]
[
./option[@value=""][.="[trans][/trans]"]
./option[@value=""][.=""]
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
]
@ -528,7 +528,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
[@name="name"]
[not(@required)]
[
./option[@value=""][.="[trans][/trans]"]
./option[@value=""][.=""]
/following-sibling::option[@value="&a"][not(@selected)][.="[trans]Choice&A[/trans]"]
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
]
@ -605,7 +605,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
[@name="name"]
[@required="required"]
[
./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]
./option[@value=""][not(@selected)][not(@disabled)][.=""]
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
]
@ -1233,15 +1233,15 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
[
./select
[@id="name_month"]
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]]
[./option[@value=""][not(@selected)][not(@disabled)][.=""]]
[./option[@value="1"][@selected="selected"]]
/following-sibling::select
[@id="name_day"]
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]]
[./option[@value=""][not(@selected)][not(@disabled)][.=""]]
[./option[@value="1"][@selected="selected"]]
/following-sibling::select
[@id="name_year"]
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]]
[./option[@value=""][not(@selected)][not(@disabled)][.=""]]
[./option[@value="1950"][@selected="selected"]]
]
[count(./select)=3]