Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[WIP][Form] Allow to configure selectable locale and countries#28542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[WIP][Form] Allow to configure selectable locale and countries#28542
Uh oh!
There was an error while loading.Please reload this page.
Conversation
327449e toa199522Comparero0NL commentedSep 21, 2018
What about a more generic |
yceruto commentedSep 21, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I think it's already supported in user land: $supportedCountries = ['FR','ES','CU'];$builder->add('country', CountryType::class, ['choice_loader' =>newIntlCallbackChoiceLoader(function ()use ($supportedCountries) {returnarray_intersect(array_flip(Intl::getRegionBundle()->getCountryNames()),$supportedCountries); }),]) Although I'm not opposed to adding a shortcut for Intl form types. |
ro0NL commentedSep 21, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
vs. $builder->add('country', CountryType::class, ['choice_filter' =>function ($countryName)use ($supportedCountries) {returnin_array($countryName,$supportedCountries,true); }),]) or just saying :) |
yceruto commentedSep 21, 2018
ro0NL commentedSep 21, 2018
Right, cool :) so i'm not the only one. The feature would be priceless,@sstok WDYT? |
yceruto commentedSep 21, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
That ( |
ro0NL commentedSep 21, 2018
Yes or pre-defined choice loaders like Intl. The main advantage is you dont have to (re)define a new choice loader basically. Thus knowing about the labels, etc. In your last example it could just as well be a |
yceruto commentedSep 21, 2018
Yeah, true :) |
sstok commentedSep 23, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I took a deep dive into the Choice loading system, and almost drowned 🦈 ! The way the choices are loaded does not allow for filtering after their list is created, the loader provides a list and only modifying the loader implementation (which is not always possible) would make it possible to filter the choices before the ChoiseList is created. There is no other option (no pun) but use custom options for each types. But allowing a Closure for a custom filtering (like Edit: I added support for closures. |
ro0NL commentedSep 23, 2018
Isnt it possible to add a |
yceruto commentedSep 24, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@sstok today I can investigate about this |
sstok commentedSep 25, 2018
@yceruto Feel free to do 😄 this thing is driving me crazy. |
yceruto commentedSep 26, 2018
See alternative with |
xabbuh commentedOct 1, 2018
sstok commentedFeb 7, 2019
Whoops, a bit late :) yes I agree this can be closed in favor of#28624 |
Thisfixes#11847, and I added support for countries as well. It should be possible to update the other types also, but languages is more tricky because
encould mean many different specific locales (this needs some thought if accepted).