[Form] Fix ChoiceType translation domain

This commit is contained in:
Vincent Langlet 2020-07-08 12:13:35 +02:00 committed by Nicolas Grekas
parent 13982b5809
commit 2effda79ea
2 changed files with 19 additions and 1 deletions

View File

@ -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',
];

View File

@ -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
*/