<?php
declare(strict_types=1);
namespace App\Form\EventSubscriber\MaxFirmware;
use App\Entity\Customer\CustomerGroup;
use App\Form\Type\Firmware\MaxFirmwareGroupsType;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
class MaxFirmwareGroupsFieldSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [FormEvents::PRE_SET_DATA => 'onPreSetData'];
}
public function onPreSetData(FormEvent $event): void
{
$form = $event->getForm();
$form->add('groups', MaxFirmwareGroupsType::class, [
'class' => CustomerGroup::class,
'choice_label' => 'name',
'multiple' => true,
'expanded' => true,
'required' => false,
]);
}
}