Skip to content

Commit 4f4e797

Browse files
ChoiceType values are not translated by default (#3859)
1 parent 05e4a09 commit 4f4e797

File tree

9 files changed

+33
-8
lines changed

9 files changed

+33
-8
lines changed

src/Form/Admin/Advert/AdvertFormType.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
8787
t('HTML code') => Advert::TYPE_CODE,
8888
t('Image with link') => Advert::TYPE_IMAGE,
8989
],
90-
'choice_translation_domain' => false,
9190
'expanded' => true,
9291
'multiple' => false,
9392
'constraints' => [

src/Form/Admin/Article/ArticleFormType.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
111111
t('Site') => Article::TYPE_SITE,
112112
t('Link') => Article::TYPE_LINK,
113113
],
114-
'choice_translation_domain' => false,
115114
'expanded' => true,
116115
'multiple' => false,
117116
'label' => t('Type'),

src/Form/Admin/Category/CategoryFormType.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
152152
'required' => false,
153153
'multiple' => true,
154154
'expanded' => true,
155-
'choice_translation_domain' => false,
156155
'choices' => $this->categoryAutomatedFilterFacade->getAllValuesIndexedByLabel(),
157156
'choice_attr' => function ($choice, $key, $value) use ($categoryAutomatedFiltersNotesIndexedByValue) {
158157
$iconTitle = $categoryAutomatedFiltersNotesIndexedByValue[$value] ?? null;

src/Form/Admin/Complaint/ComplaintFormType.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ private function createBasicInformationGroup(
145145
'label' => t('Resolution'),
146146
'required' => true,
147147
'choices' => $this->complaintResolutionEnum->getAllIndexedByTranslations(),
148-
'choice_translation_domain' => false,
149148
'multiple' => false,
150149
'expanded' => false,
151150
'attr' => [

src/Form/Admin/Customer/RoleGroup/CustomerUserRoleGroupFormType.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
5050
'multiple' => true,
5151
'expanded' => true,
5252
'choices' => $this->customerUserRole->getAvailableRoles(),
53-
'choice_translation_domain' => false,
5453
]);
5554

5655
$builder->add('actionBar', ActionBarType::class, [

src/Form/Admin/PriceList/ImportPriceListFormType.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
5151
'choices' => $this->priceListFacade->getAll(),
5252
'choice_label' => 'name',
5353
'choice_value' => 'id',
54-
'choice_translation_domain' => false,
5554
'group_by' => function (PriceList $priceList) {
5655
return $this->domain->getDomainConfigById($priceList->getDomainId())->getName();
5756
},

src/Form/Admin/PromoCode/PromoCodeFlagType.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
5050
t('Products with this flag') => PromoCodeFlag::TYPE_INCLUSIVE,
5151
t('Products without this flag') => PromoCodeFlag::TYPE_EXCLUSIVE,
5252
],
53-
'choice_translation_domain' => false,
5453
'expanded' => true,
5554
'multiple' => false,
5655
'constraints' => [

src/Form/Admin/PromoCode/PromoCodeFormType.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ private function buildBaseGroup(FormBuilderInterface $builder): void
125125
'expanded' => true,
126126
'multiple' => false,
127127
'choices' => $this->promoCodeTypeEnum->getAllIndexedByTranslations(),
128-
'choice_translation_domain' => false,
129128
'label' => t('Discount type'),
130129
'attr' => [
131130
'class' => 'js-promo-code-discount-type',

src/Form/ChoiceTypeExtension.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Shopsys\FrameworkBundle\Form;
6+
7+
use Override;
8+
use Symfony\Component\Form\AbstractTypeExtension;
9+
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
10+
use Symfony\Component\OptionsResolver\OptionsResolver;
11+
12+
class ChoiceTypeExtension extends AbstractTypeExtension
13+
{
14+
/**
15+
* @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
16+
*/
17+
#[Override]
18+
public function configureOptions(OptionsResolver $resolver): void
19+
{
20+
$resolver->setDefaults([
21+
'choice_translation_domain' => false,
22+
]);
23+
}
24+
25+
/**
26+
* @return iterable
27+
*/
28+
#[Override]
29+
public static function getExtendedTypes(): iterable
30+
{
31+
yield ChoiceType::class;
32+
}
33+
}

0 commit comments

Comments
 (0)