<?php
declare(strict_types=1);
namespace App\Form;
use App\Entity\User;
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\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
use Symfony\Component\Validator\Exception\InvalidOptionsException;
use Symfony\Component\Validator\Exception\MissingOptionsException;
/**
* Class RegisterType.
*/
final class RegisterType extends AbstractType
{
/**
* @throws ConstraintDefinitionException
* @throws InvalidOptionsException
* @throws MissingOptionsException
*/
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name', TextType::class, [
'label' => false,
'empty_data' => '',
'attr' => ['class' => 'form-control r-carousel-item-control', 'placeholder' => 'Prénom*'],
])
->add('lastname', TextType::class, [
'label' => false,
'empty_data' => '',
'attr' => ['class' => 'form-control r-carousel-item-control', 'placeholder' => 'Nom*'],
])
->add('email', EmailType::class, [
'label' => false,
'empty_data' => '',
'attr' => ['class' => 'form-control r-carousel-item-control', 'placeholder' => 'Votre email*'],
])
->add('recaptcha', EWZRecaptchaType::class, [
'label' => false,
'constraints' => [new RecaptchaTrue()],
'mapped' => false,
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => User::class,
'validation_groups' => ['register'],
'csrf_protection' => true,
'csrf_token_id' => 'security_register_item',
'csrf_field_name' => 'security_register_token',
'translation_domain' => 'user',
]);
}
}