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

[Form] Support Translatable Enum#50931

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

Merged
derrabus merged 1 commit intosymfony:6.4fromSeb33300:enum-translatable
Jul 24, 2023

Conversation

@Seb33300
Copy link
Contributor

@Seb33300Seb33300 commentedJul 11, 2023
edited
Loading

QA
Branch?6.4
Bug fix?no
New feature?yes
Deprecations?no
TicketsFix#50919
LicenseMIT
Doc PRsymfony/symfony-docs#18599

This PR introduce support for Enum implementingTranslatableInterface inEnumType.

Example of use:

$builder->add('textAlign', EnumType::class, ['class' => TextAlign::class,])
useSymfony\Contracts\Translation\TranslatableInterface;useSymfony\Contracts\Translation\TranslatorInterface;enum TextAlign:intimplements TranslatableInterface{case Left =1;case Center =2;case Right =3;publicfunctiontrans(TranslatorInterface$translator,string$locale =null):string    {// Translate enum from name (Left, Center or Right)return$translator->trans($this->name, locale:$locale);// Translate enum from custom labelsreturnmatch ($this) {self::Left   =>$translator->trans('Left aligned', locale:$locale),self::Center =>$translator->trans('Centered', locale:$locale),self::Right  =>$translator->trans('Right aligned', locale:$locale),        };    }}

yceruto and SVillette reacted with thumbs up emojiro0NL, seb-jean, and florentdestremau reacted with rocket emoji
@Seb33300
Copy link
ContributorAuthor

Just created the documentation PR:symfony/symfony-docs#18599

@derrabus
Copy link
Member

Thank you@Seb33300.

@derrabusderrabus merged commit47b95f2 intosymfony:6.4Jul 24, 2023
@Seb33300Seb33300 deleted the enum-translatable branchJuly 24, 2023 14:59
OskarStark added a commit to symfony/symfony-docs that referenced this pull requestJul 27, 2023
This PR was squashed before being merged into the 6.4 branch.Discussion----------[Form] Support Translatable EnumDocumentation forsymfony/symfony#50931Commits-------5f59527 [Form] Support Translatable Enum
This was referencedOct 21, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@derrabusderrabusderrabus approved these changes

@ycerutoycerutoyceruto approved these changes

@xabbuhxabbuhAwaiting requested review from xabbuhxabbuh is a code owner

+1 more reviewer

@ro0NLro0NLro0NL left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

6.4

Development

Successfully merging this pull request may close these issues.

Support translatable Enum in Forms

5 participants

@Seb33300@derrabus@ro0NL@yceruto@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp