<?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 Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
class RegistrationFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('firstName')
->add('lastName')
->add('companyName')
->add('email', EmailType::class, [
'required' => true,
])
->add('agreeTerms', CheckboxType::class, [
'mapped' => false,
'required' => true,
'constraints' => [
new IsTrue([
'message' => 'You should agree to our terms.',
]),
],
])
->add('plainPassword', PasswordType::class, [
// instead of being set onto the object directly,
// this is read and encoded in the controller
'mapped' => false,
'required' => true,
'attr' => ['autocomplete' => 'new-password'],
'constraints' => [
new NotBlank([
'message' => 'Le mot de passe ne peut être vide',
]),
new Length([
'min' => 6,
'minMessage' => 'Votre mot de passe doit avoir au moins {{ limit }} caractères',
// max length allowed by Symfony for security reasons
'max' => 4096,
]),
],
])
->add('phoneNumber', TextType::class, [
'label' => 'Numéro de téléphone',
'required' => true,
'attr' => [
'placeholder' => 'Entrez votre numéro de téléphone',
'class' => 'phone-number', // Ajoutez une classe pour cibler le champ avec JS
],
])
/*->add('wordpressUrl', TextType::class, [
'required' => false,
'attr' => [
'placeholder' => 'https://www.votresite.fr',
],
])
->add('wordpressUsername', TextType::class, [
'required' => false,
'attr' => [
'placeholder' => 'Nom d\'utilisateur admin du site wordpress',
],
])
->add('wordpressPassword', PasswordType::class, [
'required' => false,
'attr' => [
'placeholder' => 'Mot de passe d\'application de votre site wordpress',
],
])
->add('seoPlugin', ChoiceType::class, [
'choices' => [
'YoastSEO' => 'yoastseo',
'Rankmath' => 'rankmath',
],
'expanded' => false, // false pour un dropdown, true pour des boutons radio
'multiple' => false, // false pour une seule sélection, true pour multi-sélection
])
->add('autoPublish')*/;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => User::class,
]);
}
}