<?php
declare(strict_types=1);
namespace App\Form\EventListener\Global;
use App\Form\FormHelper;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\Extension\Core\Type\TimeType;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
class AddEndingTimeFieldSubscriber extends FormHelper implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [FormEvents::PRE_SET_DATA => 'preSetData'];
}
public function preSetData(FormEvent $event): void
{
$event->getForm()->add('endingTime', TimeType::class, $this->getTimeParameters('app.global.fields.end', self::PLACEHOLDER_DATETIME, true, [
'attr' => ['class' => 'time'],
]));
}
}