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.  
  40.         ->add('message'TextareaType::class, [
  41.             'required' => true,
  42.             'attr' => [
  43.                 'class' => 'form-control mt-1 mb-1 rounded','placeholder' => "Message",
  44.                 'style' =>'height: 180px'
  45.             ],
  46.             'label' => false])
  47.             
  48.         ->add('captcha'Recaptcha3Type::class, [
  49.             'constraints' => new Recaptcha3(),
  50.             'action_name' => 'contact',
  51.                 'constraints' => new Recaptcha3 ([
  52.                 'message' => 'karser_recaptcha3.message',
  53.                 'messageMissingValue' => 'karser_recaptcha3.message_missing_value',
  54.             ]),
  55.         ])   
  56.         /*
  57.         ->add('captcha', CaptchaType::class, [
  58.             'required' => true,
  59.             'label' => 'Saisissez le texte ci-dessus',
  60.             'attr' => [
  61.                 'class' => 'form-control mb-1 captcha',
  62.                 'style' =>'width: 100%'
  63.             ],])  
  64.             */
  65.         ->add('submit'SubmitType::class, [
  66.             'attr' => [
  67.                 'class' => 'btn-contact rounded',
  68.                 'style' =>'font-family: arial'
  69.             ],
  70.             'label' => 'Envoyer',
  71.         ]);
  72.         // ...
  73.     }
  74.     
  75.     // public function configureOptions(OptionsResolver $resolver): void
  76.     // {
  77.     //     $resolver->setDefaults([
  78.     //         'data_class' => Actualites::class,
  79.     //     ]);
  80.     // }
  81. }