Country field for local default Country in symfony 2

廉价感情. 提交于 2019-12-12 01:56:20

问题


How to use Locale::getDefault() for country field or in choice field with country names?

I have tried ->add('agentCity','country') but I don't know how to use Locale::getDefault()


回答1:


You can easily create a dropdown list of languages using the language field type: http://symfony.com/doc/current/reference/forms/types/language.html.

Then you can specify the default value using empty_data, assuming that Locale::getDefault() is in the languages list:

$form->add('agentCity', 'language', array('empty_data' => Locale::getDefault()));


来源:https://stackoverflow.com/questions/27514842/country-field-for-local-default-country-in-symfony-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!