src/Form/EventListener/Country/Global/AddCountriesFieldSubscriber.php line 21

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Form\EventListener\Country\Global;
  4. use App\Entity\Country;
  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 AddCountriesFieldSubscriber 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('countries'EntityType::class, $this->getEntityParameters(
  19.             Country::class,
  20.             'app.global.fields.countries',
  21.             self::PLACEHOLDER_CUSTOM,
  22.             true,
  23.             [
  24.                 'multiple' => true,
  25.             ]
  26.         ));
  27.     }
  28. }