Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Conversation

@sstok
Copy link
Contributor

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#11847
LicenseMIT
Doc PR"to do"

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 becauseen could mean many different specific locales (this needs some thought if accepted).

@sstoksstokforce-pushed the11847-form-add-locales-option-to-localetype branch from327449e toa199522CompareSeptember 21, 2018 14:58
@ro0NL
Copy link
Contributor

What about a more genericchoice_filter: <callable> option, covering any choice type and allowing anyone to mutate choices as needed.

yceruto and Pictor13 reacted with thumbs up emoji

@nicolas-grekasnicolas-grekas added this to thenext milestoneSep 21, 2018
@yceruto
Copy link
Member

yceruto commentedSep 21, 2018
edited
Loading

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
Copy link
Contributor

ro0NL commentedSep 21, 2018
edited
Loading

vs.

$builder->add('country', CountryType::class, ['choice_filter' =>function ($countryName)use ($supportedCountries) {returnin_array($countryName,$supportedCountries,true);    }),])

or'choice_filter' => $supportedCountries as a shortcut

just saying :)

yceruto, sstok, and Pictor13 reacted with thumbs up emoji

@yceruto
Copy link
Member

See#14072 and#18334

ro0NL reacted with thumbs up emoji

@ro0NL
Copy link
Contributor

Right, cool :) so i'm not the only one. The feature would be priceless,@sstok WDYT?

Pictor13 reacted with thumbs up emoji

@yceruto
Copy link
Member

yceruto commentedSep 21, 2018
edited
Loading

That (choice_filter) option would be especially useful for child types that need to filter the choices list built in the parent type, without having to duplicate the logic of thechoice_loader, right? Otherwise, it can be done in the samechoice_loader option.

sstok and Pictor13 reacted with thumbs up emoji

@ro0NL
Copy link
Contributor

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 aChoiceType directly (or at least you dont really rely onCountryType anymore).

sstok and Pictor13 reacted with thumbs up emoji

@yceruto
Copy link
Member

In your last example it could just as well be a ChoiceType directly (or at least you dont really rely on CountryType anymore).

Yeah, true :)

@sstok
Copy link
ContributorAuthor

sstok commentedSep 23, 2018
edited
Loading

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$k[0, 2] === 'EN') would a good feature, in practice this allows an array of accepted choices and closure to filter the choices (for more advanced use cases).

Edit: I added support for closures.

@ro0NL
Copy link
Contributor

There is no other option (no pun) but use custom options for each types.

Isnt it possible to add aFilterChoiceList and a decorating choice loader. If the choice_filter option is passed we decorate the choice loader (or use the callback choice loader) and return aFilterChoiceList instead (which also decorates).

@yceruto
Copy link
Member

yceruto commentedSep 24, 2018
edited
Loading

@sstok today I can investigate about thischoice_filter, do you mind if I make an alternative proposal?

sstok reacted with thumbs up emoji

@sstok
Copy link
ContributorAuthor

@yceruto Feel free to do 😄 this thing is driving me crazy.

yceruto reacted with laugh emoji

@yceruto
Copy link
Member

See alternative withchoice_filter#28607

@xabbuh
Copy link
Member

Thank you for your engagement in this@sstok! 👍 Do you agree to close here in favour of#28624?

sstok reacted with thumbs up emoji

@sstok
Copy link
ContributorAuthor

Whoops, a bit late :) yes I agree this can be closed in favor of#28624

@sstoksstok closed thisFeb 7, 2019
@sstoksstok deleted the 11847-form-add-locales-option-to-localetype branchFebruary 7, 2019 14:37
@nicolas-grekasnicolas-grekas modified the milestones:next,4.3Apr 30, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

4.3

Development

Successfully merging this pull request may close these issues.

[Form] add "locales" option to LocaleType

6 participants

@sstok@ro0NL@yceruto@xabbuh@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp