Take the 2-minute tour ×

I am trying to create a nationality from field using Symfony2.1:

    parent::buildForm($builder, $options);

I managed to display the country:

{{user.nationality | country  }}

The "value" for each country is the two-letter country code.

Is there a way to display the nationality from the 2-letter country code instead?

I don't think there is a twig filter for this.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You could create a Twig filter that does something like this:

use Symfony\Component\Locale\Locale;

return Locale::getDisplayCountries($locale)[$countryCode];
share|improve this answer

Your Answer


