src/Form/NewInscriptionFormType.php line 29

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