Open
Description
Description
With the introduction of TranslatableMessage in #37670 (https://symfony.com/blog/new-in-symfony-5-2-translatable-objects) and being able to use this in form label and help in #41717, it makes all the translation_parameters options kind of obsolete and duplicates alot of functionality. So we should make sure that TranslatableMessage can be used in all relevant form options and then we should deprecate
label_translation_parameters
(reverting https://symfony.com/blog/new-in-symfony-4-3-improved-form-translation)help_translation_parameters
attr_translation_parameters
invalid_message_parameters
choice_translation_parameters
(reverting [Form] Add "choice_translation_parameters" option #38469) (choice_label callback should be able to return TranslatableMessage)
The translation_domain option can likely be kept as it also serves as a way to disable translation and uses domain inheritance.
Example https://symfony.com/doc/current/reference/forms/types/choice.html#choice-translation-parameters
before:
$builder->add('id', null, [
'choices' => [
'form.order.yes' => true,
'form.order.no' => false,
],
'choice_translation_parameters' => function ($choice, $key, $value) {
if (false === $choice) {
return [];
}
return ['%company%' => 'ACME Inc.']
},
]);
could be achieved with:
$builder->add('id', null, [
'choices' => [
'form.order.yes' => true,
'form.order.no' => false,
],
'choice_label' => function ($choice, $key, $value) {
return new TranslatableMessage($key, false === $choice ? [] : ['%company%' => 'ACME Inc.']);
},
]);