src/Form/NewsletterType.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Newsletter;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  6. use Symfony\Component\Form\FormBuilderInterface;
  7. use Symfony\Component\OptionsResolver\OptionsResolver;
  8. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  9. class NewsletterType extends AbstractType
  10. {
  11.     protected $router;
  12.     public function __construct(UrlGeneratorInterface $router)
  13.     {
  14.         $this->router $router;
  15.     }
  16.     public function buildForm(FormBuilderInterface $builder, array $options): void
  17.     {
  18.         $builder
  19.             ->add('name'null, [
  20.                 "label" => "newsletter_type.name.placeholder",
  21. //                "attr" => ["placeholder" => "newsletter_type.name.placeholder"]
  22.             ])
  23.             ->add('email'null, [
  24.                 "label" => "newsletter_type.email.placeholder",
  25. //                "attr" => ["placeholder" => "newsletter_type.email.placeholder"]
  26.             ])
  27.             ->add("condition"CheckboxType::class, [
  28.                 "mapped" => false,
  29.                 "required" => true,
  30.                 "label_attr" => [
  31.                     "class" => "fw-400 checkbox-custom"
  32.                 ],
  33.                 'label' => 'contact_type.condition_label',
  34.                 'label_translation_parameters' => [
  35.                     '%url%' => $this->router->generate('front_privacy_policy'),
  36.                 ],
  37.                 "label_html" => true,
  38.             ])
  39.             ->setAction($this->router->generate("front_subscribe_newsletter"));
  40.     }
  41.     public function configureOptions(OptionsResolver $resolver): void
  42.     {
  43.         $resolver->setDefaults([
  44.             'data_class' => Newsletter::class,
  45.         ]);
  46.     }
  47. }