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

This commit is contained in:
Restless-ET 2015-06-16 10:52:18 +01:00 committed by Tobias Schultze
parent 3ef7a1f6d6
commit 1a5c4c6c93
3 changed files with 8 additions and 8 deletions

View File

@ -57,7 +57,7 @@
{%- endif -%} {%- endif -%}
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}> <select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
{%- if empty_value is not none -%} {%- 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 -%} {%- endif -%}
{%- if preferred_choices|length > 0 -%} {%- if preferred_choices|length > 0 -%}
{% set options = preferred_choices %} {% set options = preferred_choices %}

View File

@ -7,7 +7,7 @@
)) ?> )) ?>
<?php if ($multiple): ?> multiple="multiple"<?php endif ?> <?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 if (count($preferred_choices) > 0): ?>
<?php echo $view['form']->block($form, 'choice_widget_options', array('choices' => $preferred_choices)) ?> <?php echo $view['form']->block($form, 'choice_widget_options', array('choices' => $preferred_choices)) ?>
<?php if (count($choices) > 0 && null !== $separator): ?> <?php if (count($choices) > 0 && null !== $separator): ?>

View File

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