src/Form/InscriptionCertyouFormType.php line 83

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