From 2effda79ea4399883eaca11cdc47169c26280138 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Wed, 8 Jul 2020 12:13:35 +0200 Subject: [PATCH] [Form] Fix ChoiceType translation domain --- .../Form/Extension/Core/Type/ChoiceType.php | 2 +- .../Extension/Core/Type/ChoiceTypeTest.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index 1e506bf168..fccb64b39d 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -386,7 +386,7 @@ class ChoiceType extends AbstractType 'value' => $choiceView->value, 'label' => $choiceView->label, 'attr' => $choiceView->attr, - 'translation_domain' => $options['translation_domain'], + 'translation_domain' => $options['choice_translation_domain'], 'block_name' => 'entry', ]; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php index 9b2b0e64a5..ce795517b8 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -1994,6 +1994,24 @@ class ChoiceTypeTest extends BaseTypeTest $this->assertEquals('_09name', $view->vars['full_name']); } + public function testSubFormTranslationDomain() + { + $form = $this->factory->create(static::TESTED_TYPE, null, [ + 'label' => 'label', + 'translation_domain' => 'label_translation_domain', + 'choices' => [ + 'choice1' => true, + 'choice2' => false, + ], + 'choice_translation_domain' => 'choice_translation_domain', + 'expanded' => true, + ])->createView(); + + $this->assertCount(2, $form->children); + $this->assertSame('choice_translation_domain', $form->children[0]->vars['translation_domain']); + $this->assertSame('choice_translation_domain', $form->children[1]->vars['translation_domain']); + } + /** * @dataProvider provideTrimCases */