src/Form/EventListener/Admin/Aliment/AddAlimentTranslationsFieldSubscriber.php line 21

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Form\EventListener\Admin\Aliment;
  4. use App\Form\Admin\Aliment\AlimentTranslationType;
  5. use App\Form\FormHelper;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. use Symfony\Component\Form\Extension\Core\Type\CollectionType;
  8. use Symfony\Component\Form\FormEvent;
  9. use Symfony\Component\Form\FormEvents;
  10. class AddAlimentTranslationsFieldSubscriber 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('alimentTranslations'CollectionType::class, $this->getCollectionParameters(
  19.             AlimentTranslationType::class,
  20.             [],
  21.             false
  22.         ));
  23.     }
  24. }