src/Form/InscriptionFormType.php line 23

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