src/Form/ContactType.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Contact;
  4. use EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType;
  5. use EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrue as RecaptchaTrue;
  6. use Symfony\Component\Form\AbstractType;
  7. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. class ContactType extends AbstractType
  11. {
  12.     public function buildForm(FormBuilderInterface $builder, array $options): void
  13.     {
  14.         $builder->add('email')
  15.                 ->add('phone')
  16.                 ->add('object', ChoiceType::class, [
  17.                     'choices' => [
  18.                         'Demande d\'inscription' => 1,
  19.                         'Demande d\'information' => 2,
  20.                         'Réclamation' => 3,
  21.                     ],
  22.                 ]
  23.                 )
  24.             ->add('message')
  25.             ->add('recaptcha', EWZRecaptchaType::class, ['attr' => ['options' => ['theme' => 'light', 'type' => 'image', 'size' => 'invisible', 'defer' => true, 'async' => true, 'callback' => 'onReCaptchaSuccessContact', 'bind' => 'submitButtonContact']], 'mapped' => false, 'constraints' => [new RecaptchaTrue()]]);
  26.     }
  27.     public function configureOptions(OptionsResolver $resolver): void
  28.     {
  29.         $resolver->setDefaults(['data_class' => Contact::class]);
  30.     }
  31.     public function getBlockPrefix(): string
  32.     {
  33.         return 'odmquotyfdj_bundle';
  34.     }
  35. }