src/Form/ContactFormType.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. // use App\Entity\Actualites;
  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 Gregwar\CaptchaBundle\Type\CaptchaType;
  9. use Karser\Recaptcha3Bundle\Form\Recaptcha3Type;
  10. use Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3;
  11. // use Symfony\Component\OptionsResolver\OptionsResolver;
  12. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  13. use Symfony\Component\Form\Extension\Core\Type\TextType;
  14. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  15. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  16. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  17. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  18. class ContactFormType extends AbstractType
  19. {
  20.     public function buildForm(FormBuilderInterface $builder, array $options): void
  21.     {
  22.         $builder
  23.         ->add('nom'TextType::class, [
  24.             'required' => true,
  25.             'attr' => [
  26.                 'class' => 'form-control mt-1 mb-1 rounded','placeholder' => "Nom et Prénom(s)",
  27.             ],
  28.             'label' => false])
  29.         ->add('email'EmailType::class, [
  30.             'required' => true,
  31.             'attr' => [
  32.                 'class' => 'form-control mt-1 mb-1 rounded','placeholder' => "Adresse email",
  33.             ],
  34.             'label' => false])
  35.         ->add('sujet'TextType::class, [
  36.             'attr' => [
  37.                 'class' => 'form-control mt-1 mb-1 rounded','placeholder' => "Objet",
  38.             ],
  39.             'label' => false])
  40.         
  41.         ->add('besoin'ChoiceType::class, [
  42.             'attr' => [
  43.                 'class' => 'form-control mt-1 mb-1 rounded',
  44.                 'style' => 'color: #ededed;',
  45.             ],
  46.             'choices'  => [
  47.                 'Formation' => 'formation',
  48.                 'Conseil' => 'conseil',
  49.                 'Récrutement' => 'récrutement',
  50.                 'Technologie' => 'technologie',
  51.                 'Autre' => 'autre',
  52.             ],
  53.             'expanded' => true,
  54.             'multiple' => true,
  55.             'label' => false]) 
  56.         
  57.             
  58.         ->add('contact'TextType::class, [
  59.             'attr' => [
  60.                 'class' => 'form-control mt-1 mb-1 rounded','placeholder' => "Téléphone",
  61.             ],
  62.             'label' => false])
  63.  
  64.         ->add('message'TextareaType::class, [
  65.             'required' => true,
  66.             'attr' => [
  67.                 'class' => 'form-control mt-1 mb-1 rounded','placeholder' => "Message",
  68.                 'style' =>'height: 180px'
  69.             ],
  70.             'label' => false])
  71.         /*    
  72.         ->add('captcha', Recaptcha3Type::class, [
  73.             'constraints' => new Recaptcha3(),
  74.             'action_name' => 'contact',
  75.                 'constraints' => new Recaptcha3 ([
  76.                 'message' => 'karser_recaptcha3.message',
  77.                 'messageMissingValue' => 'karser_recaptcha3.message_missing_value',
  78.             ]),
  79.         ])   
  80.         ->add('captcha', CaptchaType::class, [
  81.             'required' => true,
  82.             'label' => 'Saisissez le texte ci-dessus',
  83.             'attr' => [
  84.                 'class' => 'form-control mb-1 captcha',
  85.                 'style' =>'width: 100%'
  86.             ],])  
  87.             */
  88.         ->add('recaptchaToken'HiddenType::class, [
  89.             'mapped' => false,
  90.         ])
  91.         ->add('submit'SubmitType::class, [
  92.             'attr' => [
  93.                 'class' => 'btn-contact rounded',
  94.                 'style' =>'font-family: arial'
  95.             ],
  96.             'label' => 'Envoyer',
  97.         ]);
  98.         // ...
  99.     }
  100.     
  101.     // public function configureOptions(OptionsResolver $resolver): void
  102.     // {
  103.     //     $resolver->setDefaults([
  104.     //         'data_class' => Actualites::class,
  105.     //     ]);
  106.     // }
  107. }