In my parameters.yml I have this:
parameters:
locale: en-gb
In my user entity I have this:
/**
* @ORM\Column(name="Country", type="string", length=2)
* @Assert\Country(message = "The country '{{ value }}' is not a valid country.")
* @Assert\NotBlank()
*/
private $country;
When I use a form, the validation complains that: "The country 'US' is not a valid country."
So I had a hunt around in: /src/Symfony/Component/Validator/Constraints/CountryValidator
And came across:
$countries = Intl::getRegionBundle()->getCountryNames();
So I stuck that in my code to see what was in it. What was in it, was this:
array(1) { ["UM"]=> string(27) "U.S. Minor Outlying Islands" }
Rather than the 258 countries it should have.
If I change my locale to en instead of en-gb, I get the 258 countries in the array.
So, my question is whether my parameters.yml should look like this?
parameters:
locale: en, en-gb
Or some such? So that it takes everything from en and overrides what is needed with en-gb.
Or is this a bug? (It seems this was a bug in the version I was using. 2.3.1 and is now fixed in 2.3.5) - Thanks to Ritter for this information.
I believe this is a bug, as the same code works correctly in Symfony 2.1.
I have raised a bug report here:
https://github.com/symfony/symfony/issues/9180
Please feel free to add comments, or further information.