Country field for local default Country in symfony

2019-09-03 21:06发布

问题:

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()));