<?php
namespace App\Form;
use App\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\IsTrue;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use VictorPrdh\RecaptchaBundle\Form\ReCaptchaType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
class RegistrationFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('email',null,['attr' => ['class'=>'form-control'],])
->add('agreeTerms', CheckboxType::class, [
'label' => 'Je reconnais avoir lu et accepté les <a href="/conditions-de-vente.html" style="color:#FFF;font-weight: bold;"> Conditions Générales d\'Inscription</a>',
'mapped' => false,
'label_html' => true,
'constraints' => [
new IsTrue([
'message' => 'You should agree to our terms.',
]),
],
])
->add('hasOptin',null,[
'label' => 'Je souhaite recevoir la Newsletter Croq\'Vacances '
])
->add("recaptcha", ReCaptchaType::class)
->add('plainPassword', PasswordType::class, [
// instead of being set onto the object directly,
// this is read and encoded in the controller
'mapped' => false,
'label' => 'Mot de passe',
'attr' => ['autocomplete' => 'new-password','class'=>'form-control'],
'constraints' => [
new NotBlank([
'message' => 'Please enter a password',
]),
new Length([
'min' => 8,
'minMessage' => 'Votre mot de passe doit être composé d\'au moins 8 caractères',
// max length allowed by Symfony for security reasons
'max' => 4096,
]),
],
])->add('csrf_token', HiddenType::class, [
'mapped' => false,
'data' => $options['csrf_token'],
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => User::class,
'csrf_protection' => false,
'csrf_token' => null,
]);
}
}