src/Form/EventListener/Global/AddTaxFieldSubscriber.php line 21

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