src/Form/DemandeformationFormType.php line 23

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