Fix translations of form fields in admin for social actions

This commit is contained in:
Julie Lenaerts 2025-07-02 13:56:41 +02:00
parent 8ed5e35f1a
commit 6f7015b152
2 changed files with 11 additions and 9 deletions

View File

@ -0,0 +1,6 @@
kind: Fixed
body: 'Fix translations for social action fields in admin form: results, goals, evaluations'
time: 2025-07-02T13:55:34.599050626+02:00
custom:
Issue: ""
SchemaChange: No schema change

View File

@ -25,21 +25,14 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* Class SocialActionType.
*/
class SocialActionType extends AbstractType
{
/**
* @var TranslatableStringHelper
*/
protected $translatableStringHelper;
public function __construct(TranslatableStringHelper $translatableStringHelper)
{
$this->translatableStringHelper = $translatableStringHelper;
}
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly TranslatorInterface $translator) {}
public function buildForm(FormBuilderInterface $builder, array $options)
{
@ -64,6 +57,7 @@ class SocialActionType extends AbstractType
->add('results', EntityType::class, [
'class' => Result::class,
'required' => false,
'label' => $this->translator->trans('person_admin.social_result'),
'multiple' => true,
'attr' => ['class' => 'select2'],
'choice_label' => fn (Result $r) => $this->translatableStringHelper->localize($r->getTitle()),
@ -74,6 +68,7 @@ class SocialActionType extends AbstractType
'required' => false,
'multiple' => true,
'attr' => ['class' => 'select2'],
'label' => $this->translator->trans('person_admin.social_goal'),
'choice_label' => fn (Goal $g) => $this->translatableStringHelper->localize($g->getTitle()),
])
@ -82,6 +77,7 @@ class SocialActionType extends AbstractType
'required' => false,
'multiple' => true,
'attr' => ['class' => 'select2'],
'label' => $this->translator->trans('person_admin.social_evaluation'),
'choice_label' => fn (Evaluation $e) => $this->translatableStringHelper->localize($e->getTitle()),
])