Using addModelTransformer and createNamedBuilder
Hello,
I'am using a2lix/TranslationFormBundle with KnpLabs\DoctrineBehaviors. I added translations field to my form : $builder->add('translations', TranslationsType::class, [ 'fields' => [ 'content' => [ 'field_type' => TextareaType::class, 'label' => 'admin.form.label.content', 'required' => true, ], ] ]);
Before using a2lix/TranslationFormBundle , I have :
-
[ ] $builder->get('content')->addModelTransformer(new HTMLTransformer());
-
[ ] $builder = $form->getConfig()->getFormFactory()->createNamedBuilder('subject', TextType::class, null,
['label' => 'admin.form.label.subject', 'auto_initialize' => false] );
subject field should be translated.
How can I use addModelTransformer and createNamedBuilder with translated fields ?
Thanks.
Hi @amsouissi
The content field is now a child of translations, so something along $builder->get('translations')->get('content') (not tested) ?