8000 [Form][choice] disable translate choices for Intl and Timezone form t… · symfony/symfony@0a90cf8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0a90cf8

Browse files
committed
[Form][choice] disable translate choices for Intl and Timezone form types.
1 parent cc32189 commit 0a90cf8

File tree

9 files changed

+14
-11
lines changed

9 files changed

+14
-11
lines changed

src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
{{- block('choice_widget_options') -}}
8080
</optgroup>
8181
{%- else -%}
82-
<option value="{{ choice.value }}"{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ translate_choices is sameas(false) ? choice.label : choice.label|trans({}, translation_domain) }}</option>
82+
<option value="{{ choice.value }}"{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ translate_choices ? choice.label|trans({}, translation_domain) : choice.label }}</option>
8383
{%- endif -%}
8484
{% endfor %}
8585
{%- endblock choice_widget_options -%}

src/Symfony/Component/Form/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CHANGELOG
44
2.7.0
55
-----
66

7-
* added options "translate_choices" to ChoiceType.
7+
* added option "translate_choices" to ChoiceType.
88
* deprecated the overwriting of AbstractType::setDefaultOptions() in favor of overwriting AbstractType::configureOptions().
99
* deprecated the overwriting of AbstractTypeExtension::setDefaultOptions() in favor of overwriting AbstractTypeExtension::configureOptions().
1010

src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,8 @@ public function configureOptions(OptionsResolver $resolver)
238238
$resolver->setNormalizer('empty_value', $placeholderNormalizer);
239239
$resolver->setNormalizer('placeholder', $placeholderNormalizer);
240240

241-
$resolver->setAllowedTypes(array(
242-
'choice_list' => array('null', 'Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface'),
243-
'translate_choices' => 'bool',
244-
));
241+
$resolver->setAllowedTypes('choice_list', array('null', 'Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface'));
242+
$resolver->setAllowedTypes('translate_choices', array('bool'));
245243
}
246244

247245
/**

src/Symfony/Component/Form/Extension/Core/Type/CountryType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function configureOptions(OptionsResolver $resolver)
2424
{
2525
$resolver->setDefaults(array(
2626
'choices' => Intl::getRegionBundle()->getCountryNames(),
27+
'translate_choices' => false,
2728
));
2829
}
2930

src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function configureOptions(OptionsResolver $resolver)
2424
{
2525
$resolver->setDefaults(array(
2626
'choices' => Intl::getCurrencyBundle()->getCurrencyNames(),
27+
'translate_choices' => false,
2728
));
2829
}
2930

src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function configureOptions(OptionsResolver $resolver)
2424
{
2525
$resolver->setDefaults(array(
2626
'choices' => Intl::getLanguageBundle()->getLanguageNames(),
27+
'translate_choices' => false,
2728
));
2829
}
2930

src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function configureOptions(OptionsResolver $resolver)
2424
{
2525
$resolver->setDefaults(array(
2626
'choices' => Intl::getLocaleBundle()->getLocaleNames(),
27+
'translate_choices' => false,
2728
));
2829
}
2930

src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public function configureOptions(OptionsResolver $resolver)
3030
{
3131
$resolver->setDefaults(array(
3232
'choices' => self::getTimezones(),
33+
'translate_choices' => false,
3334
));
3435
}
3536

src/Symfony/Component/Form/Tests/AbstractLayoutTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ public function testCountry()
915915
$this->assertWidgetMatchesXpath($form->createView(), array(),
916916
'/select
917917
[@name="name"]
918-
[./option[@value="AT"][@selected="selected"][.="[trans]Austria[/trans]"]]
918+
[./option[@value="AT"][@selected="selected"][.="Austria"]]
919919
[count(./option)>200]
920920
'
921921
);
@@ -932,7 +932,7 @@ public function testCountryWithPlaceholder()
932932
'/select
933933
[@name="name"]
934934
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Country[/trans]"]]
935-
[./option[@value="AT"][@selected="selected"][.="[trans]Austria[/trans]"]]
935+
[./option[@value="AT"][@selected="selected"][.="Austria"]]
936936
[count(./option)>201]
937937
'
938938
);
@@ -1456,7 +1456,7 @@ public function testLanguage()
14561456
$this->assertWidgetMatchesXpath($form->createView(), array(),
14571457
'/select
14581458
[@name="name"]
1459-
[./option[@value="de"][@selected="selected"][.="[trans]German[/trans]"]]
1459+
[./option[@value="de"][@selected="selected"][.="German"]]
14601460
[count(./option)>200]
14611461
'
14621462
);
@@ -1469,7 +1469,7 @@ public function testLocale()
14691469
$this->assertWidgetMatchesXpath($form->createView(), array(),
14701470
'/select
14711471
[@name="name"]
1472-
[./option[@value="de_AT"][@selected="selected"][.="[trans]German (Austria)[/trans]"]]
1472+
[./option[@value="de_AT"][@selected="selected"][.="German (Austria)"]]
14731473
[count(./option)>200]
14741474
'
14751475
);
@@ -1836,7 +1836,7 @@ public function testTimezone()
18361836
[not(@required)]
18371837
[./optgroup
18381838
[@label="[trans]Europe[/trans]"]
1839-
[./option[@value="Europe/Vienna"][@selected="selected"][.="[trans]Vienna[/trans]"]]
1839+
[./option[@value="Europe/Vienna"][@selected="selected"][.="Vienna"]]
18401840
]
18411841
[count(./optgroup)>10]
18421842
[count(.//option)>200]

0 commit comments

Comments
 (0)
0