-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Fix ChoiceType translation domain #37521
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I think this should be merged into 3.4 as a bugfix. |
Can we add a test to prevent future regressions? |
I started my branch from the 3.4. I just took the wrong one for the PR. It's fixed :) |
Done @xabbuh |
d6b2e20
to
2effda7
Compare
Thank you @VincentLanglet. |
@nicolas-grekas @VincentLanglet @xabbuh This change caused a regression in https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig#L304 Our radio button labels are not translated anymore unless I add Symfony 4.4.10 Symfony 4.4.11 Prior to this change, we did not had to configure the translation domain because "messages" was the default and labels were translated automatically. |
@XWB Thanks for the report. I am going to look into it. |
It seems to be expected. In the DoctrineType, there is the following config:
Prior to this fix, the Now the FormType correctly use the
is needed if you save translation key in your database. |
@VincentLanglet I understand, but it was the default behavior for years, so now all our radio buttons are broken. In my opinion that's a BC break. |
I understand that the situation is annoying, but it's not because a bug is old that it's a BC break. People shouldn't expect the choice to be translated when they use
The choice was translated. How can you not call this a bug ? That's not what the documentation explains. And when using
The choices wasn't translated, this is also an issue. I completely understand that this bug + the fact that the EntityType had the option to false by default should have mistaken a lot of user. I don't know if a message can/should be added to the Changelog to alert users about this. WDYT ? |
I understand, though that was not entirely my use case. Unlike your example, I never specified
An entry at https://symfony.com/blog/ would have been nice. It took me almost 2 hours to figure out what was going on between Symfony 4.4.10 and 4.4.11. |
Yes but the EntityType was using The changelog should have been
Or a PR could be make to set |
Unfortunately that was never really clear from the documentation, as no default value is specified in the docs: https://symfony.com/doc/current/reference/forms/types/entity.html#choice-translation-domain
I agree. |
This could worth a PR ! Do you want to make it @XWB ? |
It looks like a default template is included, any idea how I could address this change without altering the other form types? |
I don't know :( |
see symfony/symfony-docs#14220 for the documentation update |
Thank you @xabbuh |
…prevent further regressions (xabbuh) This PR was merged into the 3.4 branch. Discussion ---------- [DoctrineBridge] add choice_translation_domain tests to prevent further regressions | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Fix ##37521 (comment) | License | MIT | Doc PR | Commits ------- 7775b37 add choice_translation_domain tests to prevent further regressions
…e types (xabbuh) This PR was merged into the 3.4 branch. Discussion ---------- fix default value of choice_translation_domain for choice types fixes symfony/symfony#37521 (comment) Commits ------- c0a42de fix default value of choice_translation_domain for choice types
When using
I discovered that the choices was not translated.
Seems like it's because the subForm is using the
translation_domain
instead of thechoice_translation_domain
.