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