<?php
namespace App\Form;
use App\Entity\Evolution;
use EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaV3Type;
use EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrueV3;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class EvolutionType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('customer_information', CustomerInformationType::class, [
'label' => false,
])
->add('description', TextareaType::class, [
'label' => 'Décrivez votre besoin *',
'required' => true,
'attr' => [
'class' => 'form-control',
'rows' => '5',
],
])
->add('url', UrlType::class, [
'label' => 'Si votre demande concèrne un site déjà existant, merci de donner l\'URL de ce site',
'required' => false,
])
->add('recaptcha', EWZRecaptchaV3Type::class, [
'action_name' => 'contact',
'constraints' => [
new IsTrueV3(),
],
'attr' => [
'theme' => 'light',
'type' => 'image',
'size' => 'invisible', // set size to invisible
'defer' => true,
'async' => true,
'callback' => 'onReCaptchaSuccess', // callback will be set by default if not defined (along with JS function that validate the form on success)
'bind' => 'btn_submit', // this is the id of the form submit button
],
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Evolution::class,
]);
}
}