src/Form/DemandeformationFormType.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Demandeformations;
  4. use Symfony\Component\Form\AbstractType;
  5. use FOS\CKEditorBundle\Form\Type\CKEditorType;
  6. use Symfony\Component\Form\FormBuilderInterface;
  7. use Symfony\Component\Validator\Constraints\File;
  8. use Symfony\Component\OptionsResolver\OptionsResolver;
  9. use Symfony\Component\Form\Extension\Core\Type\UrlType;
  10. use Symfony\Component\Form\Extension\Core\Type\FileType;
  11. use Symfony\Component\Form\Extension\Core\Type\TextType;
  12. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  13. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  14. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  15. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  16. use Karser\Recaptcha3Bundle\Form\Recaptcha3Type;
  17. use Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3;
  18. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  19. class DemandeformationFormType 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.                 'Mlle' => 'Mademoiselle',
  34.             ],
  35.             'label' => 'Civilité <span style="color:red">*</span>',
  36.             'label_html' => true,])
  37.             
  38.         ->add('theme'TextType::class, [
  39.             'required' => true,
  40.             'attr' => [
  41.                 'class' => 'form-control',
  42.             ],
  43.             'label' => 'Thème de la formation souhaité <span style="color:red">*</span>',
  44.             'label_html' => true,])
  45.         ->add('lieu'TextType::class, [
  46.             'required' => true,
  47.             'attr' => [
  48.                 'class' => 'form-control mt-1 mb-1',
  49.                 'minlenght' => '2',
  50.                 'maxlenght' => '100'
  51.             ],
  52.             'label' => 'Lieu de la formation souhaité <span style="color:red">*</span>',
  53.             'label_html' => true,])
  54.         ->add('duree'TextType::class, [
  55.             'required' => true,
  56.             'attr' => [
  57.                 'class' => 'form-control mt-1 mb-1',
  58.                 'minlenght' => '2',
  59.                 'maxlenght' => '100'
  60.             ],
  61.             'label' => 'Date de la formation souhaitée <span style="color:red">*</span>',
  62.             'label_html' => true,])
  63.             
  64.         ->add('nombrepart'TextType::class, [
  65.             'required' => true,
  66.             'attr' => [
  67.                 'class' => 'form-control mt-1 mb-1',
  68.                 'minlenght' => '2',
  69.                 'maxlenght' => '100'
  70.             ],
  71.             'label' => 'Nombre de participants <span style="color:red">*</span>',
  72.             'label_html' => true,])    
  73.         ->add('fonction'TextType::class, [
  74.             'required' => true,
  75.             'attr' => [
  76.                 'class' => 'form-control mt-1 mb-1',
  77.             ],
  78.             'label' => 'Fonction <span style="color:red">*</span>',
  79.             'label_html' => true,])
  80.         ->add('nom'TextType::class, [
  81.             'required' => true,
  82.             'attr' => [
  83.                 'class' => 'form-control mt-1 mb-1',
  84.             ],
  85.             'label' => 'Nom <span style="color:red">*</span>',
  86.             'label_html' => true,])
  87.         ->add('prenoms'TextType::class, [
  88.             'required' => true,
  89.             'attr' => [
  90.                 'class' => 'form-control mt-1 mb-1',
  91.             ],
  92.             'label' => 'Prénoms <span style="color:red">*</span>',
  93.             'label_html' => true,])
  94.       
  95.         ->add('mail'EmailType::class, [
  96.             'required' => true,
  97.             'attr' => [
  98.                 'class' => 'form-control mt-1 mb-1',
  99.                 'minlenght' => '2',
  100.                 'maxlenght' => '100'
  101.             ],
  102.             'label' => 'Adresse email <span style="color:red">*</span>',
  103.             'label_html' => true,])
  104.         ->add('entreprise'TextType::class, [
  105.             'required' => true,
  106.             'attr' => [
  107.                 'class' => 'form-control mt-1 mb-1',
  108.             ],
  109.             'label' => 'Entreprise <span style="color:red">*</span>',
  110.             'label_html' => true,])
  111.         ->add('siteweb'UrlType::class, [
  112.             'required' => true,
  113.             'attr' => [
  114.                 'class' => 'form-control mt-1 mb-1',
  115.             ],
  116.             'label' => "Site Web de votre Entreprise"])
  117.         ->add('telephone'TextType::class, [
  118.             'required' => true,
  119.             'attr' => [
  120.                 'class' => 'form-control mt-1 mb-1',
  121.             ],
  122.             'label' => 'Numéro de téléphone <span style="color:red">*</span>',
  123.             'label_html' => true,])
  124.           
  125.         ->add('adresse'TextType::class, [
  126.             'required' => true,
  127.             'attr' => [
  128.                 'class' => 'form-control mt-1 mb-1',
  129.             ],
  130.             'label' => "Adresse",
  131.             'label_html' => true,])    
  132.         ->add('commentaire'TextareaType::class, [
  133.             'required' => true,
  134.             'attr' => [
  135.                 'class' => 'form-control textarea',
  136.             ],
  137.             'label' => "Commentaire"])
  138.         /*    
  139.         ->add('captcha', Recaptcha3Type::class, [
  140.             'constraints' => new Recaptcha3(),
  141.             'action_name' => 'contact',
  142.                 'constraints' => new Recaptcha3 ([
  143.                 'message' => 'karser_recaptcha3.message',
  144.                 'messageMissingValue' => 'karser_recaptcha3.message_missing_value',
  145.             ]),
  146.         ]) 
  147.         */
  148.         ->add('recaptchaToken'HiddenType::class, [
  149.             'mapped' => false,
  150.         ])
  151.  
  152.         ->add('submit'SubmitType::class, [
  153.             'attr' => [
  154.                'class' => 'btn btn-primary btn-large',
  155.                'style' =>'margin-top: 20px;'
  156.            ],
  157.             'label' => 'Demander un dévis']);
  158.         // ...
  159.     }
  160.     
  161.     public function configureOptions(OptionsResolver $resolver): void
  162.     {
  163.         $resolver->setDefaults([
  164.             'data_class' => Demandeformations::class,
  165.         ]);
  166.     }
  167. }