src/Form/InscriptionFormType.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Inscriptions;
  4. use Symfony\Component\Form\AbstractType;
  5. use Gregwar\CaptchaBundle\Type\CaptchaType;
  6. use FOS\CKEditorBundle\Form\Type\CKEditorType;
  7. use Symfony\Component\Form\FormBuilderInterface;
  8. use Symfony\Component\Validator\Constraints\File;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. use Symfony\Component\Form\Extension\Core\Type\UrlType;
  11. use Symfony\Component\Form\Extension\Core\Type\FileType;
  12. use Symfony\Component\Form\Extension\Core\Type\TextType;
  13. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  14. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  15. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  16. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  17. use Karser\Recaptcha3Bundle\Form\Recaptcha3Type;
  18. use Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3;
  19. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  20. class InscriptionFormType extends AbstractType
  21. {
  22.     public function buildForm(FormBuilderInterface $builder, array $options): void
  23.     {
  24.         $builder
  25.         ->add('civilite'ChoiceType::class, [
  26.             'mapped' => false,
  27.             'attr' => [
  28.                 'class' => 'form-control',
  29.             ],
  30.             'choices'  => [
  31.                 // 'choix du rôle de l\'utilisateur' => 'choix',
  32.                 'M.' => 'Monsieur',
  33.                 'Mme' => 'Madame',
  34.                 'Mlle' => 'Mademoiselle',
  35.             ],
  36.             'label' => 'Civilité <span style="color:red">*</span>',
  37.             'label_html' => true,])
  38.         
  39.         ->add('nom'TextType::class, [
  40.             'required' => true,
  41.             'attr' => [
  42.                 'class' => 'form-control',
  43.             ],
  44.             'label' => 'Nom <span style="color:red">*</span>',
  45.             'label_html' => true,])
  46.         ->add('prenoms'TextType::class, [
  47.             'required' => true,
  48.             'attr' => [
  49.                 'class' => 'form-control mt-1 mb-1',
  50.                 'minlenght' => '2',
  51.                 'maxlenght' => '100'
  52.             ],
  53.             'label' => 'Prénoms <span style="color:red">*</span>',
  54.             'label_html' => true,])
  55.         ->add('fonction'TextType::class, [
  56.             'required' => true,
  57.             'attr' => [
  58.                 'class' => 'form-control mt-1 mb-1',
  59.                 'minlenght' => '2',
  60.                 'maxlenght' => '100'
  61.             ],
  62.             'label' => 'Fonction <span style="color:red">*</span>',
  63.             'label_html' => true,])
  64.             
  65.         ->add('telephone'TextType::class, [
  66.             'required' => true,
  67.             'attr' => [
  68.                 'class' => 'form-control mt-1 mb-1','placeholder' => "Ex: +225 0708971405",
  69.                 'minlenght' => '2',
  70.                 'maxlenght' => '100'
  71.             ],
  72.             'label' => 'Téléphone <span style="color:red">*</span>',
  73.             'label_html' => true,])    
  74.             
  75.         ->add('mail'EmailType::class, [
  76.             'required' => true,
  77.             'attr' => [
  78.                 'class' => 'form-control mt-1 mb-1',
  79.                 'minlenght' => '2',
  80.                 'maxlenght' => '100'
  81.             ],
  82.             'label' => 'Adresse email <span style="color:red">*</span>',
  83.             'label_html' => true,])
  84.         ->add('entreprise'TextType::class, [
  85.             'required' => true,
  86.             'attr' => [
  87.                 'class' => 'form-control mt-1 mb-1',
  88.             ],
  89.             'label' => 'Entreprise <span style="color:red">*</span>',
  90.             'label_html' => true,])
  91.         ->add('siteweb'UrlType::class, [
  92.             'required' => false,
  93.             'attr' => [
  94.                 'class' => 'form-control mt-1 mb-1',
  95.             ],
  96.             'label' => 'Site Web de votre Entreprise',
  97.             'label_html' => true,])
  98.         ->add('nbparticipant'TextType::class, [
  99.             'required' => true,
  100.             'attr' => [
  101.                 'class' => 'form-control mt-1 mb-1',
  102.             ],
  103.             'label' => 'Nombre de participants <span style="color:red">*</span>',
  104.             'label_html' => true,])
  105.         ->add('pays'TextType::class, [
  106.             'required' => true,
  107.             'attr' => [
  108.                 'class' => 'form-control mt-1 mb-1',
  109.             ],
  110.             'label' => 'Pays <span style="color:red">*</span>',
  111.             'label_html' => true,])
  112.         ->add('ville'TextType::class, [
  113.             'required' => true,
  114.             'attr' => [
  115.                 'class' => 'form-control mt-1 mb-1',
  116.             ],
  117.             'label' => 'Ville <span style="color:red">*</span>',
  118.             'label_html' => true,])
  119.             
  120.         ->add('boitepostale'TextType::class, [
  121.             'required' => true,
  122.             'attr' => [
  123.                 'class' => 'form-control mt-1 mb-1',
  124.             ],
  125.             'label' => "Boite postale"])    
  126.             
  127.         ->add('whatsapp'TextType::class, [
  128.             'required' => true,
  129.             'attr' => [
  130.                 'class' => 'form-control mt-1 mb-1','placeholder' => "Ex: +225 0708971405",
  131.             ],
  132.             'label_html' => true,
  133.             'label' => 'Whatsapp <span style="color:red">*</span>'])             
  134.             
  135.         ->add('adresse'TextType::class, [
  136.             'required' => false,
  137.             'attr' => [
  138.                 'class' => 'form-control mt-1 mb-1',
  139.             ],
  140.             'label' => 'Adresse  <span style="color:red">*</span>',
  141.             'label_html' => true,])    
  142.         ->add('commentaire'TextareaType::class, [
  143.             'required' => false,
  144.             'attr' => [
  145.                 'class' => 'form-control textarea',
  146.             ],
  147.             'label' => 'Commentaire',
  148.             'label_html' => true,])
  149.             
  150.         /*    
  151.         ->add('captcha', Recaptcha3Type::class, [
  152.             'constraints' => new Recaptcha3(),
  153.             'action_name' => 'contact',
  154.                 'constraints' => new Recaptcha3 ([
  155.                 'message' => 'karser_recaptcha3.message',
  156.                 'messageMissingValue' => 'karser_recaptcha3.message_missing_value',
  157.             ]),
  158.         ]) 
  159.         */
  160.         ->add('recaptchaToken'HiddenType::class, [
  161.             'mapped' => false,
  162.         ])
  163.  
  164.         ->add('submit'SubmitType::class, [
  165.             'attr' => [
  166.                'class' => 'btn btn-primary btn-large',
  167.                'style' => ' margin-top: 20px;'
  168.            ],
  169.             'label' => 'Envoyer']);
  170.         // ...
  171.     }
  172.     
  173.     public function configureOptions(OptionsResolver $resolver): void
  174.     {
  175.         $resolver->setDefaults([
  176.             'data_class' => Inscriptions::class,
  177.         ]);
  178.     }
  179. }