8000 [Form][choice] avoid trans options for entity type. · symfony/symfony@b0b0792 · GitHub
[go: up one dir, main page]

Skip to content

Commit b0b0792

Browse files
committed
[Form][choice] avoid trans options for entity type.
1 parent cad9e0f commit b0b0792

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ public function configureOptions(OptionsResolver $resolver)
171171
'choices' => null,
172172
'choice_list' => $choiceList,
173173
'group_by' => null,
174+
'trans_options' => false,
174175
));
175176

176177
$resolver->setRequired(array('class'));

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 %}>{{ choice.label|trans({}, translation_domain) }}</option>
82+
<option value="{{ choice.value }}"{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ trans_options is sameas(false) ? choice.label : choice.label|trans({}, translation_domain) }}</option>
8383
{%- endif -%}
8484
{% endfor %}
8585
{%- endblock choice_widget_options -%}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
102102
'choices' => $options['choice_list']->getRemainingViews(),
103103
'separator' => '-------------------',
104104
'placeholder' => null,
105+
'trans_options' => $options['trans_options'],
105106
));
106107

107108
// The decision, whether a choice is selected, is potentially done
@@ -231,6 +232,7 @@ public function configureOptions(OptionsResolver $resolver)
231232
// is manually set to an object.
232233
// See https://github.com/symfony/symfony/pull/5582
233234
'data_class' => null,
235+
'trans_options' => true,
234236
));
235237

236238
$resolver->setNormalizers(array(
@@ -240,6 +242,7 @@ public function configureOptions(OptionsResolver $resolver)
240242

241243
$resolver->setAllowedTypes(array(
242244
'choice_list' => array('null', 'Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface'),
245+
'trans_options' => 'bool',
243246
));
244247
}
245248

0 commit comments

Comments
 (0)
0