src/Form/ContactType.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Contact;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  6. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  7. use Symfony\Component\Form\Extension\Core\Type\CollectionType;
  8. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  12. use Symfony\Component\Validator\Constraints\NotBlank;
  13. class ContactType extends AbstractType
  14. {
  15.     private $router;
  16.     public function __construct(UrlGeneratorInterface $router)
  17.     {
  18.         $this->router $router;
  19.     }
  20.     public function getBlockPrefix()
  21.     {
  22.         return "prvdfq";
  23.     }
  24.     public function buildForm(FormBuilderInterface $builder, array $options): void
  25.     {
  26.         if (!$options["noSubject"]) {
  27.             $builder
  28.                 ->add('sknqst'ChoiceType::class, array(
  29.                     "property_path" => "subject",
  30.                     'choices' => [
  31.                         "Information Request" => "Information Request",
  32.                         "Quote Request" => "Quote Request",
  33.                         "Demo Request" => "Demo Request"
  34.                     ],
  35.                     "placeholder" => " ",
  36.                     "attr" => array(
  37.                         "class" => "selectpicker",
  38.                         "data-live-search" => "true",
  39.                     ),
  40.                     "label_attr" => array(
  41.                         "class" => "",
  42.                     ),
  43.                     'multiple' => false,
  44.                     'expanded' => false,
  45.                     "label" => "contact_type.subject.placeholder",
  46. //                "attr" => ["placeholder" => "contact_type.subject.placeholder"],
  47.                     'required' => true
  48.                 ));
  49.         }
  50.         $builder
  51.             ->add('xcktqe'null, [
  52.                 "property_path" => "lastname",
  53.                 "label" => "contact_type.lastname.placeholder",
  54.                 "constraints" => [new NotBlank()]
  55.             ])
  56.             ->add('tqraik'null, [
  57.                 "property_path" => "firstname",
  58.                 "label" => "contact_type.firstname.placeholder",
  59. //                "attr" => ["placeholder" => "contact_type.firstname.placeholder"]
  60.             ])
  61.             ->add('ffoqxj'null, [
  62.                 "property_path" => "email",
  63.                 "constraints" => [new NotBlank()],
  64.                 "label" => "contact_type.email.placeholder",
  65. //                "attr" => ["placeholder" => "contact_type.email.placeholder"],
  66.             ])
  67.             ->add('mdvzwo'null, [
  68.                 "property_path" => "phoneNumber",
  69.                 "label" => "contact_type.phoneNumber.placeholder",
  70. //                "attr" => ["placeholder" => "contact_type.phoneNumber.placeholder"],
  71.             ])
  72.             ->add('kaxlkw'null, [
  73.                 "property_path" => "society",
  74.                 "constraints" => [new NotBlank()],
  75.                 "label" => "contact_type.society.placeholder",
  76. //                "attr" => ["placeholder" => "contact_type.society.placeholder"],
  77.             ])
  78.             ->add('ahuowd'null, [
  79.                 "property_path" => "country",
  80.                 "constraints" => [new NotBlank()],
  81.                 "label" => "contact_type.country.placeholder",
  82. //                "attr" => ["placeholder" => "contact_type.country.placeholder"],
  83.             ])
  84.             ->add('dumenr'TextareaType::class, [
  85.                 "property_path" => "message",
  86.                 "constraints" => [new NotBlank()],
  87.                 "label" => "contact_type.message.placeholder",
  88.                 "attr" => [
  89.                     "rows" => 5
  90.                 ]
  91. //                "attr" => ["placeholder" => "contact_type.message.placeholder"],
  92.             ])
  93.             ->add('middlename'null, [ // Hack to prevent bots from sending the form. The field is invisible in front and if it is filled, the contact silently fail
  94.                 "label" => "Middle name*",
  95.                 "mapped" => false,
  96.             ])
  97.             ->add("pncooa"CheckboxType::class, [
  98.                 "property_path" => "condition",
  99.                 "mapped" => false,
  100.                 "required" => true,
  101.                 "attr" => ["rows" => 5],
  102.                 "label_attr" => [
  103.                     "class" => "fw-400 checkbox-custom"
  104.                 ],
  105.                 'label' => 'contact_type.condition_label',
  106.                 'label_translation_parameters' => [
  107.                     '%url%' => $this->router->generate('front_privacy_policy'),
  108.                 ],
  109.                 "label_html" => true,
  110.             ]);
  111.     }
  112.     public function configureOptions(OptionsResolver $resolver): void
  113.     {
  114.         $resolver->setDefaults([
  115.             'data_class' => Contact::class,
  116.             'noSubject' => false,
  117.         ]);
  118.     }
  119. }