src/Form/EventSubscriber/MaxFirmware/MaxFirmwareGroupsFieldSubscriber.php line 20

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Form\EventSubscriber\MaxFirmware;
  4. use App\Entity\Customer\CustomerGroup;
  5. use App\Form\Type\Firmware\MaxFirmwareGroupsType;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. use Symfony\Component\Form\FormEvent;
  8. use Symfony\Component\Form\FormEvents;
  9. class MaxFirmwareGroupsFieldSubscriber implements EventSubscriberInterface
  10. {
  11.     public static function getSubscribedEvents(): array
  12.     {
  13.         return [FormEvents::PRE_SET_DATA => 'onPreSetData'];
  14.     }
  15.     public function onPreSetData(FormEvent $event): void
  16.     {
  17.         $form $event->getForm();
  18.         $form->add('groups'MaxFirmwareGroupsType::class, [
  19.             'class' => CustomerGroup::class,
  20.             'choice_label' => 'name',
  21.             'multiple' => true,
  22.             'expanded' => true,
  23.             'required' => false,
  24.         ]);
  25.     }
  26. }