src/Form/EventListener/Global/AddLocalesFieldSubscriber.php line 21

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Form\EventListener\Global;
  4. use App\Entity\Admin\Locale;
  5. use App\Form\FormHelper;
  6. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. use Symfony\Component\Form\FormEvent;
  9. use Symfony\Component\Form\FormEvents;
  10. class AddLocalesFieldSubscriber extends FormHelper implements EventSubscriberInterface
  11. {
  12.     public static function getSubscribedEvents(): array
  13.     {
  14.         return [FormEvents::PRE_SET_DATA => 'preSetData'];
  15.     }
  16.     public function preSetData(FormEvent $event): void
  17.     {
  18.         $event->getForm()->add('locales'EntityType::class, $this->getEntityParameters(
  19.             Locale::class,
  20.             'app.global.labels.translations.label',
  21.             self::PLACEHOLDER_CHOICE,
  22.             true,
  23.             [
  24.                 'multiple' => true,
  25.             ],
  26.         ));
  27.     }
  28. }