src/Form/NewInscriptionFormType.php line 31

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Thematiques;
  4. use App\Entity\Themes;
  5. use App\Entity\Villes;
  6. use App\Entity\Inscriptionpersos ;
  7. use Symfony\Component\Form\AbstractType;
  8. use Karser\Recaptcha3Bundle\Form\Recaptcha3Type;
  9. use Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3;
  10. use FOS\CKEditorBundle\Form\Type\CKEditorType;
  11. use Symfony\Component\Form\FormBuilderInterface;
  12. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  13. use Symfony\Component\Validator\Constraints\File;
  14. use Symfony\Component\OptionsResolver\OptionsResolver;
  15. use Symfony\Component\Form\Extension\Core\Type\UrlType;
  16. use Symfony\Component\Form\Extension\Core\Type\FileType;
  17. use Symfony\Component\Form\Extension\Core\Type\TextType;
  18. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  19. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  20. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  21. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  22. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  23. class NewInscriptionFormType extends AbstractType
  24. {
  25.     public function buildForm(FormBuilderInterface $builder, array $options): void
  26.     {
  27.         $builder
  28.         ->add('civilite'ChoiceType::class, [
  29.             'mapped' => false,
  30.             'attr' => [
  31.                 'class' => 'form-control',
  32.                 'style' => 'height: 50px'
  33.             ],
  34.             'choices'  => [
  35.                 // 'choix du rôle de l\'utilisateur' => 'choix',
  36.                 'M.' => 'Monsieur',
  37.                 'Mme' => 'Madame',
  38.                 'Mlle' => 'Mademoiselle',
  39.             ],
  40.             'label' => 'Civilité <span style="color:red">*</span>',
  41.             'label_html' => true,])
  42.             
  43.         ->add('nom'TextType::class, [
  44.             'required' => true,
  45.             'attr' => [
  46.                 'class' => 'form-control',
  47.             ],
  48.             'label' => 'Nom <span style="color:red">*</span>',
  49.             'label_html' => true])
  50.         ->add('prenoms'TextType::class, [
  51.             'required' => true,
  52.             'attr' => [
  53.                 'class' => 'form-control mt-1 mb-1',
  54.                 'minlenght' => '2',
  55.                 'maxlenght' => '100'
  56.             ],
  57.             'label' => 'Prénoms <span style="color:red">*</span>',
  58.             'label_html' => true])
  59.         ->add('fonction'TextType::class, [
  60.             'required' => true,
  61.             'attr' => [
  62.                 'class' => 'form-control mt-1 mb-1',
  63.                 'minlenght' => '2',
  64.                 'maxlenght' => '100'
  65.             ],
  66.             'label' => 'Fonction <span style="color:red">*</span>',
  67.             'label_html' => true])
  68.             
  69.         ->add('telephone'TextType::class, [
  70.             'required' => true,
  71.             'attr' => [
  72.                 'class' => 'form-control mt-1 mb-1',
  73.                 'minlenght' => '2',
  74.                 'maxlenght' => '100'
  75.             ],
  76.             'label' => 'Téléphone<span style="color:red">*</span>',
  77.             'label_html' => true])
  78.             
  79.         ->add('mail'EmailType::class, [
  80.             'required' => false,
  81.             'attr' => [
  82.                 'class' => 'form-control mt-1 mb-1',
  83.                 'minlenght' => '2',
  84.                 'maxlenght' => '100'
  85.             ],
  86.             'label' => 'Adresse email <span style="color:red">*</span>',
  87.             'label_html' => true])
  88.             
  89.         ->add('entreprise'TextType::class, [
  90.             'required' => true,
  91.             'attr' => [
  92.                 'class' => 'form-control mt-1 mb-1',
  93.             ],
  94.             'label' => 'Entreprise <span style="color:red">*</span>',
  95.             'label_html' => true])
  96.         ->add('siteweb'UrlType::class, [
  97.             'required' => false,
  98.             'attr' => [
  99.                 'class' => 'form-control mt-1 mb-1',
  100.             ],
  101.             'label' => "Site Web de votre Entreprise"])
  102.         ->add('nbparticipant'TextType::class, [
  103.             'required' => true,
  104.             'attr' => [
  105.                 'class' => 'form-control mt-1 mb-1',
  106.             ],
  107.             'label' => 'Nombre de participants <span style="color:red">*</span>',
  108.             'label_html' => true])
  109.             
  110.         ->add('pays'TextType::class, [
  111.             'required' => true,
  112.             'attr' => [
  113.                 'class' => 'form-control mt-1 mb-1',
  114.             ],
  115.             'label' => 'Pays <span style="color:red">*</span>',
  116.             'label_html' => true])
  117.         ->add('ville'TextType::class, [
  118.             'required' => true,
  119.             'attr' => [
  120.                 'class' => 'form-control mt-1 mb-1',
  121.             ],
  122.             'label' => 'Ville <span style="color:red">*</span>',
  123.             'label_html' => true])
  124.             
  125.         ->add('boitepostale'TextType::class, [
  126.             'required' => false,
  127.             'attr' => [
  128.                 'class' => 'form-control mt-1 mb-1',
  129.             ],
  130.             'label' => "Boite postale"])    
  131.             
  132.         ->add('whatsapp'TextType::class, [
  133.             'required' => true,
  134.             'attr' => [
  135.                 'class' => 'form-control mt-1 mb-1',
  136.             ],
  137.             'label' => 'Whatsapp <span style="color:red">*</span>',
  138.             'label_html' => true])           
  139.             
  140.         ->add('adresse'TextType::class, [
  141.             'required' => false,
  142.             'attr' => [
  143.                 'class' => 'form-control mt-1 mb-1',
  144.             ],
  145.             'label' => "Adresse"])    
  146.             
  147.         ->add('thematique'EntityType::class, [
  148.             'class' => Thematiques::class,
  149.             'choice_label' => 'nom',
  150.             'placeholder' => 'Sélectionner la thématique'// âœ… ici
  151.             'required' => true,
  152.             'mapped' => false,
  153.             'attr' => [
  154.                 'class' => 'form-control border-2 mt-1 mb-1 select2',
  155.                 'style' => 'height: 50px'
  156.             ],
  157.             'label' => false
  158.         ])
  159.         ->add('theme'EntityType::class, [
  160.              'required' => true,
  161.              'mapped' => true,
  162.              'attr' => [
  163.                  'class' => 'form-control border-2 mt-1 mb-1 select2',
  164.                  'style' => 'height: 50px'
  165.              ],
  166.              'class' => Themes::class,
  167.              'placeholder' => 'Selectionner une thème',
  168.              'choice_label' => 'nom',
  169.              'label' => false,
  170.              ])    
  171.  
  172.         
  173.         ->add('lieu'EntityType::class, [
  174.              'required' => true,
  175.              'mapped' => true,
  176.              'attr' => [
  177.                  'class' => 'form-control border-2 mt-1 mb-1 select2',
  178.                  'style' => 'height: 50px'
  179.              ],
  180.              'class' => Villes::class,
  181.              'choices' => $options['lieux'],
  182.              'placeholder' => 'Selectionner le lieu',
  183.              'choice_label' => 'nom',
  184.              'label' => false,])  
  185.         
  186.         ->add('prix'TextType::class, [
  187.             'required' => true,
  188.             'attr' => [
  189.                 'class' => 'form-control mt-1 mb-1','placeholder' => 'Prix',
  190.             ],
  191.             'label' => false]) 
  192.             
  193.         ->add('periode'TextType::class, [
  194.             'required' => true,
  195.             'attr' => [
  196.                 'class' => 'form-control mt-1 mb-1','placeholder' => 'Période',
  197.             ],
  198.             'label' => false])   
  199.         ->add('commentaire'TextareaType::class, [
  200.             'required' => false,
  201.             'attr' => [
  202.                 'class' => 'form-control textarea',
  203.             ],
  204.             'label' => "Commentaire"])
  205.             
  206.         /*    
  207.         ->add('captcha', Recaptcha3Type::class, [
  208.             'constraints' => new Recaptcha3(),
  209.             'action_name' => 'contact',
  210.                 'constraints' => new Recaptcha3 ([
  211.                 'message' => 'karser_recaptcha3.message',
  212.                 'messageMissingValue' => 'karser_recaptcha3.message_missing_value',
  213.             ]),
  214.         ]) 
  215.         */
  216.         ->add('recaptchaToken'HiddenType::class, [
  217.             'mapped' => false,
  218.         ])
  219.         ->add('submit'SubmitType::class, [
  220.             'attr' => [
  221.                'class' => 'btn btn-primary btn-large',
  222.                'style' => 'margin-top: 20px'
  223.            ],
  224.             'label' => 'Enregistrer']);
  225.         // ...
  226.     }
  227.     
  228.     public function configureOptions(OptionsResolver $resolver): void
  229.     {
  230.         $resolver->setDefaults([
  231.             'data_class' => Inscriptionpersos::class,
  232.             'lieux' => [], // <-- déclaration de l'option personnalisée
  233.         ]);
  234.     }
  235. }