Skip to content
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

ChoiceType Field should have a choice_translation_parameters option. #36845

Closed
VincentLanglet opened this issue May 17, 2020 · 1 comment · Fixed by #38469
Closed

ChoiceType Field should have a choice_translation_parameters option. #36845

VincentLanglet opened this issue May 17, 2020 · 1 comment · Fixed by #38469

Comments

@VincentLanglet
Copy link
Contributor

Description

There is a label_translation_parameters option (cf https://symfony.com/doc/current/reference/forms/types/choice.html#label-translation-parameters). In the same way, there is a attr_translation_parameters and help_translation_parameters.

IMHO, a choice_translation_parameters option could be great.

Example

# translations/messages.en.yaml
form.order.ok: 'I want to confirm the order made to %company%'
form.order.ko: 'I want to cancel the order made to %company%'
$builder->add('order', null, [
    'choices' => [
        'form.order.ok' => true,
        'form.order.ko' => false,
    ],
    'choice_translation_parameters' => [
        '%company%' => 'ACME Inc.',
    ],
]);
@VincentLanglet
Copy link
Contributor Author

Currently,

$builder->add('order', null, [
    'choices' => [
        'form.order.ok' => true,
        'form.order.ko' => false,
    ],
    'label_translation_parameters' => [
        '%company%' => 'ACME Inc.',
    ],
]);

works, but it's weird to use a label_ option, when all the others option are prefix by choice_.

@fabpot fabpot closed this as completed Sep 6, 2020
fabpot added a commit that referenced this issue Dec 10, 2020
…centLanglet)

This PR was squashed before being merged into the 5.3-dev branch.

Discussion
----------

[Form] Add "choice_translation_parameters" option

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix #36845 <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#13677

Original PR: #36851

Commits
-------

1ce5b03 [Form] Add "choice_translation_parameters" option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants