src/Form/InscriptionCertyouFormType.php line 29

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Sessions;
  4. use App\Entity\Inscriptionpersos;
  5. use App\Repository\SessionsRepository;
  6. use Symfony\Component\Form\AbstractType;
  7. use FOS\CKEditorBundle\Form\Type\CKEditorType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\Validator\Constraints\File;
  10. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  11. use Symfony\Component\OptionsResolver\OptionsResolver;
  12. use Symfony\Component\Form\Extension\Core\Type\UrlType;
  13. use Symfony\Component\Form\Extension\Core\Type\FileType;
  14. use Symfony\Component\Form\Extension\Core\Type\TextType;
  15. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  16. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  17. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  18. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  19. use Karser\Recaptcha3Bundle\Form\Recaptcha3Type;
  20. use Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3;
  21. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  22. class InscriptionCertyouFormType extends AbstractType
  23. {
  24.     public function buildForm(FormBuilderInterface $builder, array $options): void
  25.     {
  26.         $certificat $options['certyou'];
  27.         
  28.         $builder
  29.         ->add('choix'TextType::class, [
  30.             'required' => false,
  31.             'mapped' => false,
  32.             'disabled' => true,
  33.             'attr' => [
  34.                 'class' => 'form-control',
  35.                 'readonly' => true,
  36.             ],
  37.             'label' => 'Type de formation sélectionnée'])
  38.             
  39.         ->add('types'ChoiceType::class, [
  40.             'required' => false,
  41.             'mapped' => false,
  42.             'attr' => [
  43.                 'class' => 'form-control',
  44.                 'readonly' => true,
  45.             ],
  46.             'placeholder' => 'Choisi du type',
  47.             'choices' => [
  48.                 'classe virtuelle' => 'virtuelle',
  49.                 'classe présentielle + virtuelle' => 'presentiel',
  50.             ],
  51.             'label' => 'Choix du type de formation <span style="color:red">*</span>',
  52.             'label_html' => true,])
  53.         
  54.         ->add('duree'TextType::class, [
  55.             'required' => false,
  56.             'mapped' => false,
  57.             'disabled' => true,
  58.             'attr' => [
  59.                 'class' => 'form-control',
  60.                 'readonly' => true,
  61.             ],
  62.             'label' => 'Durée de la formation <span style="color:red">*</span>',
  63.             'label_html' => true,])
  64.             
  65.         ->add('session'EntityType::class, [
  66.             'class' =>Sessions::class,
  67.             'required' => true,
  68.             'mapped' => false,
  69.             // FILTRAGE PAR CERTIFICAT
  70.             'query_builder' => function (SessionsRepository $sr) use ($certificat) {
  71.                 return $sr->createQueryBuilder('s')
  72.                     ->andWhere('s.certyou = :certificat')
  73.                     ->setParameter('certificat'$certificat)
  74.                     ->orderBy('s.session''ASC');
  75.             },
  76.             // AFFICHAGE DE LA DATE
  77.             'choice_label' => function (Sessions $session) {
  78.                 return $session->getSession();
  79.             },  
  80.             'attr' => [
  81.                 'class' => 'form-control',
  82.             ],
  83.             'label' => 'Date de la session de formation <span style="color:red">*</span>',
  84.             'label_html' => true,])            
  85.         ->add('lieu'ChoiceType::class, [
  86.             'required' => true,
  87.             'mapped' => false,
  88.             'attr' => [
  89.                 'class' => 'form-control',
  90.                 'readonly' => true,
  91.             ],
  92.             'choices'  => [
  93.                 'abidjan' => 'ABIDJAN',
  94.                 'dakar' => 'DAKAR',
  95.                 'casablanca' => 'CASABLANCA',
  96.                 'paris' => 'PARIS',
  97.             ],
  98.             'label' => 'Choix du lieu de la formation <span style="color:red">*</span>',
  99.             'label_html' => true,])
  100.         ->add('prixvirtuelle'TextType::class, [
  101.             'required' => true,
  102.             'mapped' => false,
  103.             'disabled' => true,
  104.             'attr' => [
  105.                 'class' => 'form-control mt-1 mb-1',
  106.                 'readonly' => true,
  107.                 'minlenght' => '2',
  108.                 'maxlenght' => '100'
  109.             ],
  110.             'label' => 'Prix classe(uniquement virtuelle) <span style="color:red">*</span>',
  111.             'label_html' => true,])
  112.             
  113.         ->add('prixpresentiel'TextType::class, [
  114.             'required' => true,
  115.             'mapped' => false,
  116.             'disabled' => true,
  117.             'attr' => [
  118.                 'class' => 'form-control mt-1 mb-1',
  119.                 'readonly' => true,
  120.                 'minlenght' => '2',
  121.                 'maxlenght' => '100'
  122.             ],
  123.             'label' => 'Prix classe(virtuelle + présentielle) <span style="color:red">*</span>',
  124.             'label_html' => true,])
  125.  
  126.         ->add('civilite'ChoiceType::class, [
  127.             'required' => true,
  128.             'mapped' => false,
  129.             'attr' => [
  130.                 'class' => 'form-control',
  131.             ],
  132.             'choices'  => [
  133.                 // 'choix du rôle de l\'utilisateur' => 'choix',
  134.                 'Monsieur' => 'M.',
  135.                 'Madame' => 'Mme',
  136.                 'Mademoiselle' => 'Mselle',
  137.             ],
  138.             'label' => 'Civilité <span style="color:red">*</span>',
  139.             'label_html' => true,])
  140.         
  141.         ->add('nom'TextType::class, [
  142.             'required' => true,
  143.             'attr' => [
  144.                 'class' => 'form-control',
  145.             ],
  146.             'label' => 'Nom <span style="color:red">*</span>',
  147.             'label_html' => true,])
  148.         ->add('prenoms'TextType::class, [
  149.             'required' => true,
  150.             'attr' => [
  151.                 'class' => 'form-control mt-1 mb-1',
  152.                 'minlenght' => '2',
  153.                 'maxlenght' => '100'
  154.             ],
  155.             'label' => 'Prénoms <span style="color:red">*</span>',
  156.             'label_html' => true,])
  157.         ->add('fonction'TextType::class, [
  158.             'required' => true,
  159.             'attr' => [
  160.                 'class' => 'form-control mt-1 mb-1',
  161.                 'minlenght' => '2',
  162.                 'maxlenght' => '100'
  163.             ],
  164.             'label' => 'Fonction <span style="color:red">*</span>',
  165.             'label_html' => true,])
  166.             
  167.         ->add('telephone'TextType::class, [
  168.             'required' => true,
  169.             'attr' => [
  170.                 'class' => 'form-control mt-1 mb-1','placeholder' => "Ex: +225 0708971405",
  171.                 'minlenght' => '2',
  172.                 'maxlenght' => '100'
  173.             ],
  174.             'label' => 'Téléphone <span style="color:red">*</span>',
  175.             'label_html' => true,])    
  176.             
  177.         ->add('mail'EmailType::class, [
  178.             'required' => true,
  179.             'attr' => [
  180.                 'class' => 'form-control mt-1 mb-1',
  181.                 'minlenght' => '2',
  182.                 'maxlenght' => '100'
  183.             ],
  184.             'label' => 'Adresse email <span style="color:red">*</span>',
  185.             'label_html' => true,])
  186.         ->add('entreprise'TextType::class, [
  187.             'required' => true,
  188.             'attr' => [
  189.                 'class' => 'form-control mt-1 mb-1',
  190.             ],
  191.             'label' => 'Entreprise <span style="color:red">*</span>',
  192.             'label_html' => true,])
  193.         ->add('siteweb'UrlType::class, [
  194.             'required' => false,
  195.             'attr' => [
  196.                 'class' => 'form-control mt-1 mb-1',
  197.             ],
  198.             'label' => 'Site Web de votre Entreprise',
  199.             'label_html' => true,])
  200.         ->add('nbparticipant'TextType::class, [
  201.             'required' => true,
  202.             'attr' => [
  203.                 'class' => 'form-control mt-1 mb-1',
  204.             ],
  205.             'label' => 'Nombre de participants <span style="color:red">*</span>',
  206.             'label_html' => true,])
  207.         ->add('pays'TextType::class, [
  208.             'required' => true,
  209.             'attr' => [
  210.                 'class' => 'form-control mt-1 mb-1',
  211.             ],
  212.             'label' => 'Pays <span style="color:red">*</span>',
  213.             'label_html' => true,])
  214.         ->add('ville'TextType::class, [
  215.             'required' => true,
  216.             'attr' => [
  217.                 'class' => 'form-control mt-1 mb-1',
  218.             ],
  219.             'label' => 'Ville <span style="color:red">*</span>',
  220.             'label_html' => true,])
  221.             
  222.         ->add('boitepostale'TextType::class, [
  223.             'required' => true,
  224.             'attr' => [
  225.                 'class' => 'form-control mt-1 mb-1',
  226.             ],
  227.             'label' => "Boite postale"])    
  228.             
  229.         ->add('whatsapp'TextType::class, [
  230.             'required' => true,
  231.             'attr' => [
  232.                 'class' => 'form-control mt-1 mb-1','placeholder' => "Ex: +225 0708971405",
  233.             ],
  234.             'label_html' => true,
  235.             'label' => 'Whatsapp <span style="color:red">*</span>'])             
  236.             
  237.         ->add('adresse'TextType::class, [
  238.             'required' => true,
  239.             'attr' => [
  240.                 'class' => 'form-control mt-1 mb-1',
  241.             ],
  242.             'label' => 'Adresse  <span style="color:red">*</span>',
  243.             'label_html' => true,])    
  244.         ->add('commentaire'TextareaType::class, [
  245.             'required' => false,
  246.             'attr' => [
  247.                 'class' => 'form-control textarea',
  248.             ],
  249.             'label' => 'Commentaire',
  250.             'label_html' => true,])
  251.         /*    
  252.         ->add('captcha', Recaptcha3Type::class, [
  253.             'constraints' => new Recaptcha3(),
  254.             'action_name' => 'contact',
  255.                 'constraints' => new Recaptcha3 ([
  256.                 'message' => 'karser_recaptcha3.message',
  257.                 'messageMissingValue' => 'karser_recaptcha3.message_missing_value',
  258.             ]),
  259.         ]) 
  260.         */
  261.         ->add('recaptchaToken'HiddenType::class, [
  262.             'mapped' => false,
  263.         ])
  264.         
  265.         ->add('submit'SubmitType::class, [
  266.             'attr' => [
  267.                'class' => 'btn btn-primary btn-large',
  268.                'style' => 'font-family: arial'
  269.            ],
  270.             'label' => 'Envoyer']);    
  271.             
  272.     }
  273.     
  274.     public function configureOptions(OptionsResolver $resolver): void
  275.     {
  276.         $resolver->setDefaults([
  277.             'data_class' => null,
  278.             'certyou' => null,
  279.         ]);
  280.     }
  281. }