66
77use Sylius \Bundle \ChannelBundle \Form \Type \ChannelChoiceType ;
88use Sylius \Bundle \LocaleBundle \Form \Type \LocaleChoiceType ;
9+ use Sylius \Bundle \ResourceBundle \Form \DataTransformer \ResourceToIdentifierTransformer ;
910use Sylius \Bundle \ResourceBundle \Form \Type \AbstractResourceType ;
11+ use Sylius \Component \Resource \Repository \RepositoryInterface ;
1012use Symfony \Component \Form \Extension \Core \Type \EmailType ;
1113use Symfony \Component \Form \FormBuilderInterface ;
14+ use Symfony \Component \Form \ReversedTransformer ;
1215
1316final class RestockNotificationAdminRequestType extends AbstractResourceType
1417{
18+ /**
19+ * @param class-string $dataClass
20+ * @param list<string> $validationGroups
21+ */
22+ public function __construct (
23+ private readonly RepositoryInterface $ localeRepository ,
24+ string $ dataClass ,
25+ array $ validationGroups = [],
26+ ) {
27+ parent ::__construct ($ dataClass , $ validationGroups );
28+ }
29+
1530 public function buildForm (FormBuilderInterface $ builder , array $ options ): void
1631 {
1732 parent ::buildForm ($ builder , $ options );
@@ -29,7 +44,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
2944 ])
3045 ->add ('email ' , EmailType::class, [
3146 'label ' => 'sylius.ui.email ' ,
32- ])
33- ;
47+ ]);
48+
49+ $ builder ->get ('localeCode ' )->addModelTransformer (
50+ new ReversedTransformer (new ResourceToIdentifierTransformer ($ this ->localeRepository , 'code ' )),
51+ );
3452 }
3553}
0 commit comments