<?php
namespace App\Form;
use App\Entity\Contact;
use EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType;
use EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrue as RecaptchaTrue;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class ContactType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('email')
->add('phone')
->add('object', ChoiceType::class, [
'choices' => [
'Demande d\'inscription' => 1,
'Demande d\'information' => 2,
'Réclamation' => 3,
],
]
)
->add('message')
->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()]]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults(['data_class' => Contact::class]);
}
public function getBlockPrefix(): string
{
return 'odmquotyfdj_bundle';
}
}