我有一个表单可以让国家选择如下:
<div class="form-group">
<label for="form[country]" class="its--col-sm-2 control-label">{{ form_label(form.country) }}</label>
<div class="its--col-sm-10">
{{ form_widget(form.country, { 'attr':{'id': 'countryForm', 'class': 'form-control'} }) }}
</div>
</div>
问题出现在AOTranslationBundle。
这是一个很棒的捆绑。在db中注册所有在视图中呈现的翻译,并在工具栏中显示它们以进行翻译。
然后,symfony country choice尝试翻译Symfony\Component\Intl\Intl::getRegionBundle()->getCountryNames()返回的所有国家/地区。
我解决了这个重写 choice_widget_options
{% form_theme form _self %}
{%- block choice_widget_options -%}
{% for group_label, choice in options %}
<option value="{{ choice.value }}"{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ choice.label }}</option>
{% endfor %}
{%- endblock choice_widget_options -%}
我的问题是......我如何才能覆盖国家/地区选择选项而不是其他选择选项?