src/Form/ContactFormType.php line 24

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. class ContactFormType extends AbstractType
  18. {
  19.     public function buildForm(FormBuilderInterface $builder, array $options): void
  20.     {
  21.         $builder
  22.         ->add('nom'TextType::class, [
  23.             'required' => true,
  24.             'attr' => [
  25.                 'class' => 'form-control mt-1 mb-1 rounded','placeholder' => "Nom et Prénom(s)",
  26.             ],
  27.             'label' => false])
  28.         ->add('email'EmailType::class, [
  29.             'required' => true,
  30.             'attr' => [
  31.                 'class' => 'form-control mt-1 mb-1 rounded','placeholder' => "Adresse email",
  32.             ],
  33.             'label' => false])
  34.         ->add('sujet'TextType::class, [
  35.             'attr' => [
  36.                 'class' => 'form-control mt-1 mb-1 rounded','placeholder' => "Objet",
  37.             ],
  38.             'label' => false])
  39.         ->add('contact'TextType::class, [
  40.             'attr' => [
  41.                 'class' => 'form-control mt-1 mb-1 rounded','placeholder' => "Téléphone",
  42.             ],
  43.             'label' => false])
  44.  
  45.         ->add('message'TextareaType::class, [
  46.             'required' => true,
  47.             'attr' => [
  48.                 'class' => 'form-control mt-1 mb-1 rounded','placeholder' => "Message",
  49.                 'style' =>'height: 180px'
  50.             ],
  51.             'label' => false])
  52.             
  53.         ->add('captcha'Recaptcha3Type::class, [
  54.             'constraints' => new Recaptcha3(),
  55.             'action_name' => 'contact',
  56.                 'constraints' => new Recaptcha3 ([
  57.                 'message' => 'karser_recaptcha3.message',
  58.                 'messageMissingValue' => 'karser_recaptcha3.message_missing_value',
  59.             ]),
  60.         ])   
  61.         /*
  62.         ->add('captcha', CaptchaType::class, [
  63.             'required' => true,
  64.             'label' => 'Saisissez le texte ci-dessus',
  65.             'attr' => [
  66.                 'class' => 'form-control mb-1 captcha',
  67.                 'style' =>'width: 100%'
  68.             ],])  
  69.             */
  70.         ->add('submit'SubmitType::class, [
  71.             'attr' => [
  72.                 'class' => 'btn-contact rounded',
  73.                 'style' =>'font-family: arial'
  74.             ],
  75.             'label' => 'Envoyer',
  76.         ]);
  77.         // ...
  78.     }
  79.     
  80.     // public function configureOptions(OptionsResolver $resolver): void
  81.     // {
  82.     //     $resolver->setDefaults([
  83.     //         'data_class' => Actualites::class,
  84.     //     ]);
  85.     // }
  86. }